github.com/feiyang21687/docker@v1.5.0/docs/sources/articles/https/make_certs.sh (about)

     1  #!/bin/bash
     2  
     3  openssl genrsa -aes256 -out ca-key.pem 2048
     4  
     5  echo "enter your Docker daemon's hostname as the 'Common Name'= ($HOST)"
     6  
     7  #TODO add this as an ENV to docker run?
     8  openssl req -new -x509 -days 365 -key ca-key.pem -sha256 -out ca.pem
     9  
    10  
    11  # server cert
    12  openssl genrsa -out server-key.pem 2048
    13  openssl req -subj "/CN=$HOST" -new -key server-key.pem -out server.csr
    14  openssl x509 -req -days 365 -in server.csr -CA ca.pem -CAkey ca-key.pem \
    15    -CAcreateserial -out server-cert.pem
    16  
    17  #client cert
    18  openssl genrsa -out key.pem 2048
    19  openssl req -subj '/CN=client' -new -key key.pem -out client.csr
    20  
    21  echo extendedKeyUsage = clientAuth > extfile.cnf
    22  openssl x509 -req -days 365 -in client.csr -CA ca.pem -CAkey ca-key.pem \
    23    -CAcreateserial -out cert.pem -extfile extfile.cnf