Generate server/client ssl cert with self CA.
You can find most commands I used were in the reference.
mkdir
1 2 3
| mkdir -p ssl/ca mkdir -p ssl/client mkdir -p ssl/server
|
generate CA first
1 2 3 4 5
| openssl genrsa -aes256 -out ssl/ca/ca-key.pem 4096
openssl req -new -x509 -days 365000 -key ssl/ca/ca-key.pem -sha256 -out ssl/ca/ca.pem
|
generate server’s key/cert
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
openssl genrsa -out ssl/server/server-key.pem 4096
openssl req -subj "/CN=pikeszfish.me" -sha256 -new -key ssl/server/server-key.pem -out ssl/server/server.csr
echo subjectAltName = DNS:pikeszfish.me,IP:127.0.0.1 > ssl/server/extfile.cnf
openssl x509 -req -days 365000 -sha256 -in ssl/server/server.csr -CA ssl/ca/ca.pem -CAkey ssl/ca/ca-key.pem -CAcreateserial -out ssl/server/server-cert.pem -extfile ssl/server/extfile.cnf
cp ssl/ca/ca.pem ssl/server/ca.pem
|
generate client’s key/cert
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| openssl genrsa -out ssl/client/client-key.pem 4096
openssl req -subj '/CN=client' -new -key ssl/client/client-key.pem -out ssl/client/client.csr
echo extendedKeyUsage = clientAuth > ssl/client/extfile.cnf
openssl x509 -req -days 365000 -sha256 -in ssl/client/client.csr -CA ssl/ca/ca.pem -CAkey ssl/ca/ca-key.pem -CAcreateserial -out ssl/client/client-cert.pem -extfile ssl/client/extfile.cnf
cp ssl/ca/ca.pem ssl/client/ca.pem
|
chmod (IMPORTANT!)
1 2
| chmod -v 400 ssl/ca/ca-key.pem ssl/server/server-key.pem ssl/client/client-key.pem chmod -v 444 ssl/ca/ca.pem ssl/server/server-cert.pem ssl/client/client-cert.pem
|
delete .csr
1 2
| rm -v ssl/client/client.csr ssl/server/server.csr
|
参考
Protect the Docker daemon socket