Created
May 1, 2017 13:29
-
-
Save lpcdma/5890f5a45eb4ada261eb6b83c580c16a to your computer and use it in GitHub Desktop.
获得证书用于java程序连接
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
HOST=myhost.example.com | |
PORT=443 | |
KEYSTOREFILE=dest_keystore | |
KEYSTOREPASS=changeme | |
# get the SSL certificate | |
openssl s_client -connect ${HOST}:${PORT} </dev/null \ | |
| sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ${HOST}.cert | |
# create a keystore and import certificate | |
keytool -import -noprompt -trustcacerts \ | |
-alias ${HOST} -file ${HOST}.cert \ | |
-keystore ${KEYSTOREFILE} -storepass ${KEYSTOREPASS} | |
# verify we've got it. | |
keytool -list -v -keystore ${KEYSTOREFILE} -storepass ${KEYSTOREPASS} -alias ${HOST} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment