Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Initial Commit. This is how I setup TLS on my computer.
- Loading branch information
Reynaldo Morillo
committed
Mar 2, 2019
0 parents
commit 1096830
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Setup TLS for Docker | ||
=============================== | ||
|
||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[Service] | ||
ExecStart= | ||
ExecStart=/usr/bin/dockerd --tlsverify --tlscacert=/home/reynaldo/.docker/ca.pem --tlscert=/home/reynaldo/.docker/server-cert.pem --tlskey=/home/reynaldo/.doc$ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/sh | ||
|
||
hostname=${1} | ||
|
||
cd ~/.docker/ | ||
|
||
openssl genrsa -aes256 -out ca-key.pem 4096 | ||
|
||
openssl req -new -x509 -days 365 -key ca-key.pem -sha256 -out ca.pem | ||
|
||
openssl genrsa -out server-key.pem 4096 | ||
|
||
openssl req -subj "/CN=$hostname" -sha256 -new -key server-key.pem -out server.csr | ||
|
||
echo subjectAltName = DNS:$hostname,IP:10.10.10.20,IP:127.0.0.1 >> 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 | ||
|
||
openssl genrsa -out key.pem 4096 | ||
|
||
openssl req -subj '/CN=client' -new -key key.pem -out client.csr | ||
|
||
echo extendedKeyUsage = clientAuth > extfile-client.cnf | ||
|
||
openssl x509 -req -days 365 -sha256 -in client.csr -CA ca.pem -CAkey ca-key.pem \ | ||
-CAcreateserial -out cert.pem -extfile extfile-client.cnf | ||
|
||
|
||
rm -v client.csr server.csr extfile.cnf extfile-client.cnf | ||
|
||
chmod -v 0400 ca-key.pem key.pem server-key.pem | ||
|
||
chmod -v 0444 ca.pem server-cert.pem cert.pem |