Skip to content

Instantly share code, notes, and snippets.

@abellmann
Last active July 4, 2017 12:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abellmann/0befb1a493ea3605d66e1ce2ed06accd to your computer and use it in GitHub Desktop.
Save abellmann/0befb1a493ea3605d66e1ce2ed06accd to your computer and use it in GitHub Desktop.
Install certificates into java keystore
$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