Skip to content

Instantly share code, notes, and snippets.

@zmax
Last active November 27, 2018 15:30
Show Gist options
  • Select an option

  • Save zmax/1534771b9f52b1365ded354bb3beff37 to your computer and use it in GitHub Desktop.

Select an option

Save zmax/1534771b9f52b1365ded354bb3beff37 to your computer and use it in GitHub Desktop.

Revisions

  1. zmax revised this gist Nov 27, 2018. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions generateCert.sh
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,8 @@

    HOST=${1}

    mkdir -p ~/.ssl

    # generate cert and key
    openssl req -newkey rsa:2048 -x509 -nodes -keyout ~/.ssl/$HOST.key -new -out ~/.ssl/$HOST.crt -subj /CN=$HOST -reqexts SAN -extensions SAN -config <(cat /System/Library/OpenSSL/openssl.cnf <(printf "[SAN]\nsubjectAltName=DNS:${HOST}")) -sha256 -days 3650
    # add to keychains
  2. zmax created this gist Nov 27, 2018.
    8 changes: 8 additions & 0 deletions generateCert.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    #!/bin/bash

    HOST=${1}

    # generate cert and key
    openssl req -newkey rsa:2048 -x509 -nodes -keyout ~/.ssl/$HOST.key -new -out ~/.ssl/$HOST.crt -subj /CN=$HOST -reqexts SAN -extensions SAN -config <(cat /System/Library/OpenSSL/openssl.cnf <(printf "[SAN]\nsubjectAltName=DNS:${HOST}")) -sha256 -days 3650
    # add to keychains
    sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ~/.ssl/${HOST}.crt