Created
August 2, 2023 10:00
-
-
Save Bludwarf/17c99471011a11af9e6831ddc4b46cc4 to your computer and use it in GitHub Desktop.
Powershell script to import certificates from a directory to a Java trust store file
This file contains hidden or 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
$source_dir = "C:\certs" | |
$keystore = "C:\Java\truststore.jks" | |
$cert_extensions = @( | |
"*.cer", | |
"*.crt", | |
"*.der", | |
"*.pem" | |
) | |
$certs = @() | |
$cert_extensions | ForEach-Object { | |
$certs += Get-ChildItem $source_dir -Filter $_ | |
} | |
$certs | Foreach-Object { | |
$cert = $_ | |
Write-Output "Import du certificat $cert" | |
keytool -import -trustcacerts -alias $cert.BaseName -file $cert.FullName -keystore $keystore -keypass changeit -storepass changeit -noprompt | |
} | |
# Source : https://stackoverflow.com/a/20886446/1655155 | |
Write-Host -NoNewLine 'Appuyer sur n''importe quelle touche pour fermer...'; | |
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment