diff --git a/docker/gencerts/Dockerfile b/docker/gencerts/Dockerfile new file mode 100644 index 00000000..2f18f40a --- /dev/null +++ b/docker/gencerts/Dockerfile @@ -0,0 +1,21 @@ +FROM debian:jessie + +RUN apt-get update && apt-get install -y openssl + +ENV OPENSSL_SUBJ="/C=CH/ST=Zuerich/L=Zuerich" +ENV OPENSSL_CA="${OPENSSL_SUBJ}/CN=demo-CA" +ENV OPENSSL_SERVER="${OPENSSL_SUBJ}/CN=demo-server" +ENV OPENSSL_CLIENT="${OPENSSL_SUBJ}/CN=demo-client" + +COPY gencerts.sh / +RUN chmod +x /gencerts.sh + +VOLUME /certs + +WORKDIR /certs + +# This works on windows +CMD openssl genrsa -out ca-key.pem 2048 && openssl req -new -x509 -key ca-key.pem -nodes -days 3600 -subj "${OPENSSL_CA}" -out ca.pem && openssl req -newkey rsa:2048 -days 3600 -nodes -subj "${OPENSSL_SERVER}" -keyout server-key.pem -out server-req.pem && openssl rsa -in server-key.pem -out server-key.pem && openssl x509 -req -in server-req.pem -days 3600 -CA ca.pem -CAkey ca-key.pem -set_serial 01 -out server-cert.pem && openssl req -newkey rsa:2048 -days 3600 -nodes -subj "${OPENSSL_CLIENT}" -keyout client-key.pem -out client-req.pem && openssl rsa -in client-key.pem -out client-key.pem && openssl x509 -req -in client-req.pem -days 3600 -CA ca.pem -CAkey ca-key.pem -set_serial 01 -out client-cert.pem && openssl verify -CAfile ca.pem server-cert.pem client-cert.pem && openssl x509 -in ca.pem -inform pem -out ca.der -outform der + +# This don't work on windows +#CMD /gencerts.sh \ No newline at end of file diff --git a/docker/gencerts/gencerts.sh b/docker/gencerts/gencerts.sh new file mode 100644 index 00000000..b86ccebf --- /dev/null +++ b/docker/gencerts/gencerts.sh @@ -0,0 +1,9 @@ +openssl genrsa -out ca-key.pem 2048 +openssl req -new -x509 -key ca-key.pem -nodes -days 3600 -subj "${OPENSSL_CA}" -out ca.pem +openssl req -newkey rsa:2048 -days 3600 -nodes -subj "${OPENSSL_SERVER}" -keyout server-key.pem -out server-req.pem +openssl rsa -in server-key.pem -out server-key.pem +openssl x509 -req -in server-req.pem -days 3600 -CA ca.pem -CAkey ca-key.pem -set_serial 01 -out server-cert.pem +openssl req -newkey rsa:2048 -days 3600 -nodes -subj "${OPENSSL_CLIENT}" -keyout client-key.pem -out client-req.pem +openssl rsa -in client-key.pem -out client-key.pem +openssl x509 -req -in client-req.pem -days 3600 -CA ca.pem -CAkey ca-key.pem -set_serial 01 -out client-cert.pem +openssl verify -CAfile ca.pem server-cert.pem client-cert.pem \ No newline at end of file diff --git a/docker/mariadb/mariadb.cnf b/docker/mariadb/mariadb.cnf new file mode 100644 index 00000000..99df9666 --- /dev/null +++ b/docker/mariadb/mariadb.cnf @@ -0,0 +1,9 @@ +[mysqld] +ssl-ca=/etc/mysql/certs/ca.pem +ssl-cert=/etc/mysql/certs/server-cert.pem +ssl-key=/etc/mysql/certs/server-key.pem + +[client] +ssl-ca=/etc/mysql/certs/ca.pem +ssl-cert=/etc/mysql/certs/client-cert.pem +ssl-key=/etc/mysql/certs/client-key.pem \ No newline at end of file