Last active
May 9, 2023 13:23
-
-
Save mavaddat/cda2bf1ec330fb87428fdf10c0425799 to your computer and use it in GitHub Desktop.
Add certs to certstore Java using keytool.exe
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
Add-Type -Assembly PresentationCore | |
<# load ConvertTo-Slug from Gist #> Invoke-Expression (New-Object -TypeName System.Net.WebClient).DownloadString('https://gist.githubusercontent.com/mavaddat/0bbed730a4c10a066d75894a7611d730/raw/4a37c2ec4f0d33ff2bbb1a224b0b901063dce871/slugify.ps1') # Imports Function ConvertTo-Slug | |
# Copy files to the clipboard in Windows explorer.exe | |
foreach ($crt in [System.Windows.Clipboard]::GetFileDropList()) | |
{ | |
$crt = $crt | Get-Item | |
$slug = $crt.Name | ConvertTo-Slug | |
if (-not (.\keytool.exe -list -alias $slug -cacerts -storepass changeit 2>&1 | Out-String | Select-String -Pattern "keytool error: java.lang.Exception: Alias <$slug> does not exist" -SimpleMatch)) | |
{ | |
.\keytool.exe -delete -cacerts -storepass changeit -alias $slug | |
} | |
.\keytool.exe -trustcacerts -cacerts -storepass changeit -importcert -alias $slug -file "$($crt.FullName)" -noprompt | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment