Created
March 3, 2014 10:20
-
-
Save threez/9322140 to your computer and use it in GitHub Desktop.
Extract and update a ldap certificate in a java keystore (jenkins)
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 | |
LDAP_SERVER=example.com:636 | |
ALIAS=LDAP_SERVER | |
KEYSTORE=/usr/lib/jvm/java-1.6.0-openjdk-amd64/jre/lib/security/cacerts | |
PASSWD=changeit | |
# grep the certificate | |
echo -n | openssl s_client -connect $LDAP_SERVER | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ldaps.crt | |
# remove the old cert | |
keytool -delete -alias $ALIAS -keystore $KEYSTORE -storepass $PASSWD | |
# install the new cert | |
keytool -import -trustcacerts -alias $ALIAS -file ldaps.crt -keystore $KEYSTORE -storepass $PASSWD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment