- The script is just a wrapper of the commands listed at https://docs.docker.com/engine/security/https/
- Switch around the HOST and HOST1 variables and run
Created
December 26, 2017 17:24
-
-
Save captn3m0/2c2e723b2dcd5cdaad733aad12be59a2 to your computer and use it in GitHub Desktop.
Docker Daemon CA setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo rm *.pem *.csr *.cnf | |
export HOST="docker.vpn.bb8.fun" | |
export HOST2="docker.in.bb8.fun" | |
openssl genrsa -aes256 -out ca-key.pem -passout pass:foobar 4096 | |
openssl genrsa -out server-key.pem 4096 | |
openssl req -subj "/CN=docker.bb8.fun" -new -x509 -days 365 -key ca-key.pem -sha256 -out ca.pem -passin pass:foobar | |
openssl req -subj "/CN=$HOST" -sha256 -new -key server-key.pem -out server.csr | |
echo subjectAltName=DNS:$HOST,DNS:$HOST2 > extfile.cnf | |
echo extendedKeyUsage=serverAuth >> extfile.cnf | |
openssl x509 -req -days 365 -sha256 -in server.csr -CA ca.pem -CAkey ca-key.pem \ | |
-CAcreateserial -out server-cert.pem -extfile extfile.cnf -passin pass:foobar | |
openssl genrsa -out key.pem 4096 | |
openssl req -subj '/CN=client' -new -key key.pem -out client.csr | |
echo extendedKeyUsage = clientAuth >> extfile.cnf | |
openssl x509 -req -days 365 -sha256 -in client.csr -CA ca.pem -CAkey ca-key.pem \ | |
-CAcreateserial -out cert.pem -extfile extfile.cnf -passin pass:foobar | |
chmod -v 0400 ca.pem key.pem server-key.pem | |
chmod -v 0444 ca.pem server-cert.pem cert.pem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment