Last active
August 9, 2024 17:38
-
-
Save mavaddat/9cc2ecfe97dd03fcd7ccd9415c05da53 to your computer and use it in GitHub Desktop.
Set Maven Certificates using certificate-ripper crip
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
&"$env:LOCALAPPDATA\Programs\certificate-ripper\crip.exe" export der --destination="$env:TEMP\certs\" --resolve-ca --url=https://repo.maven.apache.org/maven2 | |
$certs = Get-ChildItem -Path "$env:TEMP\certs\" | |
Get-Command -Name java -All | ForEach-Object { | |
$binDir = $_.Source | Split-Path -Parent | |
$keyToolPath = Join-Path -Path $binDir -ChildPath 'keytool.exe' | |
if (Test-Path -Path $keyToolPath -PathType Leaf) { | |
foreach ($cert in $certs) { | |
$hash = Get-FileHash -Path $cert -Algorithm MD5 | Select-Object -ExpandProperty Hash | |
Write-Verbose -Message "Installing cert '$cert' into '$binDir' with hash '$hash'" -Verbose | |
&$keyToolPath -delete -alias "$hash" -cacerts -storepass changeit -noprompt | |
$msg = &$keyToolPath 2>&1 -cacerts -storepass changeit -importcert -file "$cert" -alias "$hash" -noprompt | |
if($LASTEXITCODE -eq 0){ | |
Write-Verbose -Message $msg -Verbose | |
} else { | |
Write-Error -Message $msg -Verbose | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment