File: gen-test-certs.sh

package info (click to toggle)
prometheus-redis-exporter 1.69.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 768 kB
  • sloc: makefile: 121; sh: 92
file content (32 lines) | stat: -rwxr-xr-x 797 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash

# Generate test certificates:
#
#   ca.{crt,key}          Self signed CA certificate.
#   redis.{crt,key}       A certificate with no key usage/policy restrictions.

dir=`dirname $0`

# Generate CA
openssl genrsa -out ${dir}/ca.key 4096
openssl req \
    -x509 -new -nodes -sha256 \
    -key ${dir}/ca.key \
    -days 3650 \
    -subj '/O=redis_exporter/CN=Certificate Authority' \
    -out ${dir}/ca.crt

# Generate cert
openssl genrsa -out ${dir}/redis.key 2048
openssl req \
    -new -sha256 \
    -subj "/O=redis_exporter/CN=localhost" \
    -key ${dir}/redis.key | \
    openssl x509 \
        -req -sha256 \
        -CA ${dir}/ca.crt \
        -CAkey ${dir}/ca.key \
        -CAserial ${dir}/ca.txt \
        -CAcreateserial \
        -days 3650 \
        -out ${dir}/redis.crt