21 lines
623 B
PowerShell
21 lines
623 B
PowerShell
param()
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
$subject = 'CN=Local Node MITM Proxy Root CA'
|
|
$store = New-Object System.Security.Cryptography.X509Certificates.X509Store('Root', 'CurrentUser')
|
|
$store.Open('ReadWrite')
|
|
try {
|
|
$matches = @($store.Certificates | Where-Object { $_.Subject -eq $subject })
|
|
if ($matches.Count -eq 0) {
|
|
Write-Host "No matching certificate found: $subject"
|
|
exit 0
|
|
}
|
|
foreach ($cert in $matches) {
|
|
Write-Host "Removing $($cert.Subject) thumbprint=$($cert.Thumbprint)"
|
|
$store.Remove($cert)
|
|
}
|
|
Write-Host 'Removed matching root CA certificate(s).'
|
|
} finally {
|
|
$store.Close()
|
|
}
|