executable_import-cert.sh 329 B

123456789101112
  1. #!/bin/sh
  2. #
  3. # usage: import-cert.sh remote.host.name [port]
  4. #
  5. REMHOST="$1"
  6. REMPORT="${2:-443}"
  7. exec 6>&1
  8. exec > "$REMHOST"
  9. echo | openssl s_client -connect "${REMHOST}":"${REMPORT}" 2>&1 |sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p'
  10. certutil -d sql:"$HOME"/.pki/nssdb -A -t TC -n "$REMHOST" -i "$REMHOST"
  11. exec 1>&6 6>&-