Skip to content

Instantly share code, notes, and snippets.

@tjklemz
Created March 5, 2021 19:18
Show Gist options
  • Save tjklemz/f7236d82af1da1d5899f6c3da930a73b to your computer and use it in GitHub Desktop.
Save tjklemz/f7236d82af1da1d5899f6c3da930a73b to your computer and use it in GitHub Desktop.

Revisions

  1. tjklemz created this gist Mar 5, 2021.
    21 changes: 21 additions & 0 deletions setup-certs.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    # Certs https://stackoverflow.com/a/55249339/958007
    function setup-certs() {
    local cert_path="$HOME/.certs/all.pem"
    local cert_dir=$(dirname "${cert_path}")
    [[ -d "${cert_dir}" ]] || mkdir -p "${cert_dir}"
    security find-certificate -a -p /System/Library/Keychains/SystemRootCertificates.keychain > "${cert_path}"
    security find-certificate -a -p /Library/Keychains/System.keychain >> "${cert_path}"
    export GIT_SSL_CAINFO="${cert_path}"
    export AWS_CA_BUNDLE="${cert_path}"
    export NODE_EXTRA_CA_CERTS="${cert_path}"
    npm config set -g cafile "${cert_path}"
    npm config set -g strict-ssl true
    yarn config set cafile "${cert_path}" -g
    yarn config set strict-ssl true -g
    }

    function unset-certs() {
    [[ ! -f "$HOME/.certs/all.pem" ]] || rm "$HOME/.certs/all.pem";
    }

    setup-certs