Skip to content

Instantly share code, notes, and snippets.

@dukelion
Last active August 29, 2015 14:17
Show Gist options
  • Save dukelion/a6df75484478ed69ca15 to your computer and use it in GitHub Desktop.
Save dukelion/a6df75484478ed69ca15 to your computer and use it in GitHub Desktop.
import self-signed https to chrome
#!/bin/sh
#
# usage: import-cert remote.host.name [port]
#
REMHOST=$(echo $1 | sed -re 's@http(s)?://([^/]*).*@\2@')
REMPORT=${2:-443}
exec 6>&1
exec > $REMHOST
echo | openssl s_client -connect ${REMHOST}:${REMPORT} 2>&1 |sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p'
certutil -d sql:$HOME/.pki/nssdb -A -t TC -n "$REMHOST" -i $REMHOST
exec 1>&6 6>&-
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment