Created
October 18, 2019 06:21
-
-
Save entr/4113b79b4905743bfbda0aec77fe9dbc to your computer and use it in GitHub Desktop.
trust-hosts-cert.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 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