Skip to content

Commit 6e255cb

Browse files
committed
test with local client certificate
1 parent b9b29b3 commit 6e255cb

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ RUN set -ex \
1414
&& apk del openssl \
1515
&& rm -rf /var/cache/apk/* \
1616
# Delete unnecessary files
17-
&& rm package* generate-cert.sh \
17+
&& rm package* \
1818
# Correct User's file access
1919
&& chown -R node:node /app \
2020
&& chmod +r /app/privkey.pem

tests.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,13 +325,15 @@ message " Stop containers "
325325
docker stop http-echo-tests
326326

327327
message " Check that mTLS server responds with client certificate details"
328-
# Might as well just reuse any cert
329-
cp ../generate-cert.sh .
330-
bash generate-cert.sh
328+
# Generate a new self signed cert locally
329+
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout privkey.pem -out fullchain.pem \
330+
-subj "/CN=client.example.net" \
331+
-addext "subjectAltName=DNS:client.example.net"
331332
docker run -d --rm -e MTLS_ENABLE=1 --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo
332333
sleep 5
333-
COMMON_NAME="$(curl -sk --cert cert.pem --key privkey.pem https://localhost:8443/ | jq -r '.clientCertificate.subject.CN')"
334-
if [ "$COMMON_NAME" == "my.example.com" ]
334+
COMMON_NAME="$(curl -sk --cert fullchain.pem --key privkey.pem https://localhost:8443/ | jq -r '.clientCertificate.subject.CN')"
335+
SAN="$(curl -sk --cert fullchain.pem --key privkey.pem https://localhost:8443/ | jq -r '.clientCertificate.subjectaltname')"
336+
if [ "$COMMON_NAME" == "client.example.net" ] && [ "$SAN" == "DNS:client.example.net" ]
335337
then
336338
passed "Client certificate details are present in the output"
337339
else

0 commit comments

Comments
 (0)