Skip to content

Commit e19d3ce

Browse files
committed
added ability to define custom server name; fixed chrome/brave ssl issues using subjectAltName
1 parent 60f87ee commit e19d3ce

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

Dockerfile

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,32 @@ FROM alpine:latest AS symfony_h2-proxy-cert
126126

127127
RUN apk add --no-cache openssl
128128

129+
# Allow to set server name
130+
ARG SERVER_NAME="localhost"
131+
ENV SERVER_NAME=${SERVER_NAME}
132+
129133
# Use this self-generated certificate only in dev, IT IS NOT SECURE!
134+
# create the private key
130135
RUN openssl genrsa -des3 -passout pass:NotSecure -out server.pass.key 2048
131-
RUN openssl rsa -passin pass:NotSecure -in server.pass.key -out server.key
132-
RUN rm server.pass.key
136+
RUN openssl rsa -passin pass:NotSecure -in server.pass.key -out server.key \
137+
&& rm server.pass.key
138+
139+
# create a request to sign certificate
133140
RUN openssl req -new -passout pass:NotSecure -key server.key -out server.csr \
134-
-subj '/C=SS/ST=SS/L=Gotham City/O=Symfony/CN=localhost'
135-
RUN openssl x509 -req -sha256 -days 365 -in server.csr -signkey server.key -out server.crt
141+
-subj "/C=SS/ST=SS/L=Gotham City/O=Symfony/CN=${SERVER_NAME}"
142+
143+
# create an extensions configuration file
144+
RUN set -eux; \
145+
{ \
146+
echo "[ v3_ca ]"; \
147+
echo "subjectAltName = DNS:${SERVER_NAME}"; \
148+
echo "extendedKeyUsage = serverAuth"; \
149+
} > extfile.cnf
150+
151+
# create the signed certificate
152+
RUN openssl x509 -req -sha256 -extensions v3_ca -extfile extfile.cnf -days 365 \
153+
-in server.csr -signkey server.key -out server.crt \
154+
&& rm extfile.cnf
136155

137156
### "h2-proxy" stage
138157
FROM nginx:${NGINX_VERSION}-alpine AS symfony_h2-proxy

0 commit comments

Comments
 (0)