Created
September 11, 2020 08:21
-
-
Save rammanokar/c8e51853589e6b8fa678ac498b88f565 to your computer and use it in GitHub Desktop.
Add cert form URL to JKS java keystore
This file contains hidden or 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=google.com | |
| PORT=443 | |
| KEYSTOREFILE="/etc/pki/java/cacerts" | |
| KEYSTOREPASS=changeit | |
| # 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