Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 90cadcd

Browse files
authored
Add a Subject Alternative Name to the certificate generated for Complement tests. (#13071)
1 parent 0fcc0ae commit 90cadcd

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

changelog.d/13071.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add a Subject Alternative Name to the certificate generated for Complement tests.

docker/complement/conf/start_for_complement.sh

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,30 @@ fi
7373

7474
# Generate a TLS key, then generate a certificate by having Complement's CA sign it
7575
# Note that both the key and certificate are in PEM format (not DER).
76+
77+
# First generate a configuration file to set up a Subject Alternative Name.
78+
cat > /conf/server.tls.conf <<EOF
79+
.include /etc/ssl/openssl.cnf
80+
81+
[SAN]
82+
subjectAltName=DNS:${SERVER_NAME}
83+
EOF
84+
85+
# Generate an RSA key
7686
openssl genrsa -out /conf/server.tls.key 2048
7787

78-
openssl req -new -key /conf/server.tls.key -out /conf/server.tls.csr \
79-
-subj "/CN=${SERVER_NAME}"
88+
# Generate a certificate signing request
89+
openssl req -new -config /conf/server.tls.conf -key /conf/server.tls.key -out /conf/server.tls.csr \
90+
-subj "/CN=${SERVER_NAME}" -reqexts SAN
8091

92+
# Make the Complement Certificate Authority sign and generate a certificate.
8193
openssl x509 -req -in /conf/server.tls.csr \
8294
-CA /complement/ca/ca.crt -CAkey /complement/ca/ca.key -set_serial 1 \
83-
-out /conf/server.tls.crt
95+
-out /conf/server.tls.crt -extfile /conf/server.tls.conf -extensions SAN
96+
97+
# Assert that we have a Subject Alternative Name in the certificate.
98+
# (grep will exit with 1 here if there isn't a SAN in the certificate.)
99+
openssl x509 -in /conf/server.tls.crt -noout -text | grep DNS:
84100

85101
export SYNAPSE_TLS_CERT=/conf/server.tls.crt
86102
export SYNAPSE_TLS_KEY=/conf/server.tls.key

0 commit comments

Comments
 (0)