proxy/scripts/uninstall-root-ca-windows.ps1
2026-06-30 23:00:35 +08:00

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()
}