Skip to content

Commit fdc1845

Browse files
committed
Add Redis test TLS certificate generation script
1 parent 42b8175 commit fdc1845

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

redis/tls/gen-test-certs.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
# based on https://github.com/redis/redis/blob/unstable/utils/gen-test-certs.sh
4+
# Generate some test certificates which are used by the regression test suite:
5+
#
6+
# ca.{crt,key} Self signed CA certificate.
7+
# redis.{crt,key} A certificate with no key usage/policy restrictions.
8+
9+
generate_cert() {
10+
local name=$1
11+
local cn="$2"
12+
local opts="$3"
13+
14+
local keyfile=${name}.key
15+
local certfile=${name}.crt
16+
17+
[ -f $keyfile ] || openssl genrsa -out $keyfile 2048
18+
openssl req \
19+
-new -sha256 \
20+
-subj "/O=Redis Test/CN=$cn" \
21+
-key $keyfile | \
22+
openssl x509 \
23+
-req -sha256 \
24+
-CA ca.crt \
25+
-CAkey ca.key \
26+
-CAserial ca.txt \
27+
-CAcreateserial \
28+
-days 365 \
29+
$opts \
30+
-out $certfile
31+
}
32+
33+
[ -f ca.key ] || openssl genrsa -out ca.key 4096
34+
openssl req \
35+
-x509 -new -nodes -sha256 \
36+
-key ca.key \
37+
-days 3650 \
38+
-subj '/O=Redis Test/CN=Certificate Authority' \
39+
-out ca.crt
40+
41+
generate_cert redis "Generic-cert"
42+
43+
openssl pkcs12 -export -in redis.crt -inkey redis.key -out redis.p12 -passout pass:

0 commit comments

Comments
 (0)