Last active
December 19, 2015 21:29
-
-
Save wookietreiber/6020822 to your computer and use it in GitHub Desktop.
Downloads an SSL certificate and imports it into a Java keystore.
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/bash | |
KT_HOST=${KT_HOST:-$1} | |
KT_PORT=${KT_PORT:-${2:-443}} | |
KT_ALIAS=$KT_HOST:$KT_PORT | |
KT_STORE=${KT_STORE:-$3} | |
[[ -z $KT_HOST ]] && { | |
echo "usage: $(basename $0) host [port] [store]" > /dev/stderr | |
exit 1 | |
} | |
dump_certificate() { | |
echo | openssl s_client -showcerts -connect $KT_ALIAS | |
} | |
keytool -import -alias $KT_ALIAS -file <(dump_certificate) ${KT_STORE:+-keystore $KT_STORE} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment