Skip to content

Instantly share code, notes, and snippets.

@dazfuller
Last active April 29, 2016 07:01
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 dazfuller/2119f452ea88f2bacdc8b67e431fdbc9 to your computer and use it in GitHub Desktop.
Save dazfuller/2119f452ea88f2bacdc8b67e431fdbc9 to your computer and use it in GitHub Desktop.
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Error "Need to run as an administrator"
return -1
}
$source = "https://letsencrypt.org/certs/lets-encrypt-x3-cross-signed.pem"
$file = $source.Split("/")[-1]
$out = Join-Path "$($env:USERPROFILE)\Downloads" -ChildPath $file
Invoke-WebRequest -Uri $source -OutFile $out
$args = @(
"-trustcacerts"
"-keystore"
'"' + $($env:JAVA_HOME) + '\lib\security\cacerts"'
"-storepass"
"changeit"
"-noprompt"
"-importcert"
"-file"
$out
)
$process = Start-Process -FilePath $env:JAVA_HOME\bin\keytool.exe -ArgumentList $args -Wait -PassThru -NoNewWindow
@dazfuller
Copy link
Author

This assumes that the JAVA_HOME environment variable is set correctly and that keytools.exe is found under it's \bin directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment