Skip to content

Instantly share code, notes, and snippets.

@EmmanuelKasper
Last active February 14, 2016 11:47
Show Gist options
  • Save EmmanuelKasper/e5b522ad360deb00ae89 to your computer and use it in GitHub Desktop.
Save EmmanuelKasper/e5b522ad360deb00ae89 to your computer and use it in GitHub Desktop.
Add a self signed certificate to Chrome / Chromium on Linux
#!/bin/sh
# you need to install the libnss3-tools package or equivalent
if [ $# -lt 2 ]; then
echo "Usage: $0 hostname port"
exit 1
fi
hostname=$1
port=$2
echo -n | openssl s_client -connect $hostname:$port| sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /tmp/$hostname-$port.pem
# -A for adding, -t for setting the server as a "trusted peer"
certutil -d sql:$HOME/.pki/nssdb -A -t "P,," -n $hostname -i /tmp/$hostname-$port.pem
# list the current content of the nss db
certutil -d sql:$HOME/.pki/nssdb -L
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment