Skip to content
Permalink
Newer
Older
100755 36 lines (19 sloc) 1011 Bytes
1
#!/bin/sh
2
3
hostname=${1}
4
5
cd ~/.docker/
6
7
openssl genrsa -aes256 -out ca-key.pem 4096
8
9
openssl req -new -x509 -days 365 -key ca-key.pem -sha256 -out ca.pem
10
11
openssl genrsa -out server-key.pem 4096
12
13
openssl req -subj "/CN=$hostname" -sha256 -new -key server-key.pem -out server.csr
14
15
echo subjectAltName = DNS:$hostname,IP:10.10.10.20,IP:127.0.0.1 >> extfile.cnf
16
17
echo extendedKeyUsage = serverAuth >> extfile.cnf
18
19
openssl x509 -req -days 365 -sha256 -in server.csr -CA ca.pem -CAkey ca-key.pem \
20
-CAcreateserial -out server-cert.pem -extfile extfile.cnf
21
22
openssl genrsa -out key.pem 4096
23
24
openssl req -subj '/CN=client' -new -key key.pem -out client.csr
25
26
echo extendedKeyUsage = clientAuth > extfile-client.cnf
27
28
openssl x509 -req -days 365 -sha256 -in client.csr -CA ca.pem -CAkey ca-key.pem \
29
-CAcreateserial -out cert.pem -extfile extfile-client.cnf
30
31
32
rm -v client.csr server.csr extfile.cnf extfile-client.cnf
33
34
chmod -v 0400 ca-key.pem key.pem server-key.pem
35
36
chmod -v 0444 ca.pem server-cert.pem cert.pem
You can’t perform that action at this time.