Skip to content

Instantly share code, notes, and snippets.

@sdague
Created September 10, 2014 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sdague/a05c4290e709978cec3d to your computer and use it in GitHub Desktop.
Save sdague/a05c4290e709978cec3d to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# usage: import-cert.sh remote.host.name [port]
#
REMHOST=$1
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 P,, -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