Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save devdudeio/ece3211ddcf22214cfb98984ab9dae2f to your computer and use it in GitHub Desktop.
Save devdudeio/ece3211ddcf22214cfb98984ab9dae2f to your computer and use it in GitHub Desktop.

Revisions

  1. @Artistan Artistan revised this gist Jan 25, 2018. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion add_cert.sh
    Original file line number Diff line number Diff line change
    @@ -12,8 +12,11 @@ f=~/$1$d.cer
    touch $f
    touch $p

    # path added -- brew openssl....
    # echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc

    # get pem file
    /usr/local/Cellar/openssl/1.0.2n/bin/openssl s_client -showcerts -connect "$1:443" -servername $1 </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > $p
    openssl s_client -showcerts -connect "$1:443" -servername $1 </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > $p
    # https://stackoverflow.com/questions/13732826/convert-pem-to-crt-and-key
    openssl x509 -inform PEM -in $p -outform DER -out $f

  2. @Artistan Artistan revised this gist Jan 24, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion add_cert.sh
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@ touch $f
    touch $p

    # get pem file
    /usr/local/Cellar/openssl/1.0.2n/bin/openssl s_client -showcerts -connect "$1:443" </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > $p
    /usr/local/Cellar/openssl/1.0.2n/bin/openssl s_client -showcerts -connect "$1:443" -servername $1 </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > $p
    # https://stackoverflow.com/questions/13732826/convert-pem-to-crt-and-key
    openssl x509 -inform PEM -in $p -outform DER -out $f

  3. @Artistan Artistan revised this gist Jan 24, 2018. 1 changed file with 20 additions and 6 deletions.
    26 changes: 20 additions & 6 deletions add_cert.sh
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,29 @@
    #!/bin/zsh
    #
    if [ -z "$1" ]; then
    echo "provide a domain as an argument"
    exit;
    fi

    touch ~/$1.pem
    d=`date +%Y-%m-%d`
    p=~/$1$d.pem
    f=~/$1$d.cer

    /usr/local/Cellar/openssl/1.0.2n/bin/openssl s_client -showcerts -connect "$1:443" </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/$1.pem
    touch $f
    touch $p

    https://github.com/laravel/homestead/pull/773
    # get pem file
    /usr/local/Cellar/openssl/1.0.2n/bin/openssl s_client -showcerts -connect "$1:443" </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > $p
    # https://stackoverflow.com/questions/13732826/convert-pem-to-crt-and-key
    openssl x509 -inform PEM -in $p -outform DER -out $f

    #cat $f;exit;
    # https://github.com/laravel/homestead/pull/773
    # https://stackoverflow.com/questions/45263265/use-ssl-on-laravel-homestead
    # https://deliciousbrains.com/ssl-certificate-authority-for-local-https-development/
    echo "adding cert $1 to trusted root certs"
    if [[ $( sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ~/$1.pem ) ]]
    echo "adding cert $f to trusted root certs"
    if [[ $( sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain $f ) ]]
    then
    echo "killing chrome to get the new certificate"
    pkill -a -i "Google Chrome"
    #pkill -a -i "Google Chrome"
    fi
  4. @Artistan Artistan created this gist Jan 24, 2018.
    10 changes: 10 additions & 0 deletions A Readme for Adding Certs.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    # Add a cert to you macbook

    ## USAGE

    `~/add_cert.sh my.intra.net`

    _you will be asked for your password to add thit to keychain_

    - downloads pem file
    - adds to trusted root certificates
    15 changes: 15 additions & 0 deletions add_cert.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    #!/bin/zsh

    touch ~/$1.pem

    /usr/local/Cellar/openssl/1.0.2n/bin/openssl s_client -showcerts -connect "$1:443" </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/$1.pem

    https://github.com/laravel/homestead/pull/773
    # https://stackoverflow.com/questions/45263265/use-ssl-on-laravel-homestead
    # https://deliciousbrains.com/ssl-certificate-authority-for-local-https-development/
    echo "adding cert $1 to trusted root certs"
    if [[ $( sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ~/$1.pem ) ]]
    then
    echo "killing chrome to get the new certificate"
    pkill -a -i "Google Chrome"
    fi