Last active
July 4, 2017 12:33
-
-
Save abellmann/0befb1a493ea3605d66e1ce2ed06accd to your computer and use it in GitHub Desktop.
Install certificates into 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
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition | |
# provide a list of jdks, where the certificates will be added | |
$java_homes = @("C:\Program Files\Java\jdk1.8.0_121\jre", "C:\Atlassian\Bitbucket\Installation\5.0.1\jre") | |
# place the root cert in the directory of this script and call it root.cer | |
$root_cert = Join-Path $scriptPath "rootCa.cer" | |
# place the intermediat cert in the directory of this script and call it intermediate.cer | |
$intermediate_cert = Join-Path $scriptPath "intermediateCa.cer" | |
foreach($java_home in $java_homes) | |
{ | |
$keytool = Join-Path $java_home "\bin\keytool.exe" | |
$cacerts = Join-Path $java_home "\lib\security\cacerts" | |
# import root certificate | |
cd "$java_home" | |
cmd /c .\bin\keytool.exe -import -alias root_cert -file "$root_cert" -keystore "$cacerts" -storepass changeit -noprompt -trustcacerts | |
# import intermediate certificate | |
cmd /c .\bin\keytool.exe -import -alias intermediate_cert -file "$intermediate_cert" -keystore "$cacerts" -storepass changeit -noprompt -trustcacerts | |
} | |
cd "$scriptPath" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment