Created
May 18, 2021 17:54
-
-
Save LannyRipple/e7a7e4e7f1c94c093a63072cfc6642a8 to your computer and use it in GitHub Desktop.
Bash script adding nexus cacert to current 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
#!/bin/bash | |
nexus=nexus.example.net:443 | |
java_home=$( java -XshowSettings:properties -version 2>&1 > /dev/null | grep 'java.home' | sed 's/.*= //' ) | |
echo -n | openssl s_client -connect $nexus |\ | |
sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /tmp/nexus.crt | |
trap "rm -f /tmp/nexus.crt" 0 2 13 14 | |
keytool -delete -trustcacerts -keystore $java_home/lib/security/cacerts -storepass changeit -noprompt -alias nexuscert | |
keytool -import -trustcacerts -keystore $java_home/lib/security/cacerts -storepass changeit \ | |
-noprompt -alias nexuscert -file /tmp/nexus.crt | |
## __END__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment