Skip to content

Instantly share code, notes, and snippets.

@riy
Last active March 16, 2025 21:14
Show Gist options
  • Select an option

  • Save riy/fd387bb452b19f0ec4ba to your computer and use it in GitHub Desktop.

Select an option

Save riy/fd387bb452b19f0ec4ba to your computer and use it in GitHub Desktop.

Revisions

  1. riy renamed this gist Mar 16, 2025. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. riy revised this gist Jan 16, 2016. No changes.
  3. riy renamed this gist Jan 15, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. @astropanic astropanic created this gist Jan 14, 2016.
    18 changes: 18 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    #!/bin/bash
    HOST_IP=`ifconfig eth0| awk '/inet addr/{print substr($2,6)}'`

    mkdir docker-ca
    chmod 0700 docker-ca
    cd docker-ca
    openssl genrsa -aes256 -out ca-key.pem 2048
    openssl req -new -x509 -days 365 -key ca-key.pem -sha256 -out ca.pem
    openssl genrsa -out server-key.pem 2048
    openssl req -subj "/CN=${HOST_IP}" -new -key server-key.pem -out server.csr
    echo subjectAltName = IP:${HOST_IP},IP:127.0.0.1 > extfile.cnf
    openssl x509 -req -days 365 -in server.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out server-cert.pem -extfile extfile.cnf
    openssl genrsa -out client-key.pem 2048
    openssl req -subj '/CN=client' -new -key client-key.pem -out client.csr
    echo extendedKeyUsage = clientAuth > extfile.cnf
    openssl x509 -req -days 365 -in client.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out client-cert.pem -extfile extfile.cnf
    chmod -v 0400 ca-key.pem client-key.pem server-key.pem
    chmod -v 0444 ca.pem server-cert.pem client-cert.pem