Skip to content

Commit 128c61c

Browse files
committed
Add simple SSL mechanism
1 parent 3d99adf commit 128c61c

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
FROM ghcr.io/oracle/oraclelinux:9
22

3-
RUN dnf install -y httpd && \
3+
RUN dnf install -y httpd mod_ssl && \
44
rm -rf /var/cache/dnf
55

6-
CMD ["httpd", "-DFOREGROUND"]
6+
ENV CERTIFICATE_DIR /etc/pki/tls/certs
7+
ENV KEY_DIR /etc/pki/tls/private
8+
9+
COPY ./entrypoint.sh /opt/entrypoint.sh
10+
11+
CMD ["/opt/entrypoint.sh"]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
set -eu pipefail
4+
5+
SERVER_CERT="$CERTIFICATE_DIR/localhost.crt"
6+
SERVER_KEY="$KEY_DIR/localhost.key"
7+
8+
if [ ! -f "$SERVER_KEY" ]; then
9+
echo "Generating certificate private key for SSL support"
10+
openssl genpkey -algorithm RSA -out "$SERVER_KEY"
11+
fi
12+
13+
if [ ! -f "$SERVER_CERT" ]; then
14+
echo "Generating self-signed certificates for SSL support"
15+
openssl req -x509 -new -nodes -key "$SERVER_KEY" -sha256 -days 3650 -out "$SERVER_CERT" -subj "/C=US/ST=California/L=San Francisco/O=Test Company/CN=localhost"
16+
fi
17+
18+
httpd -DFOREGROUND

0 commit comments

Comments
 (0)