有没有办法在 Windows 7 中快速禁用所有受信任的根证书?

zol*_*oli 5 windows-7 ssl-certificate

(我之前已将其发布给超级用户)

我想暂时禁用所有受信任的根证书,并想知道是否有比遍历每个证书更快的方法,右键单击“属性”并选择“禁用此证书的所有用途”(然后尝试找到我的位置)在 mmc 中的列表滚动回顶部后离开)?

小智 4

正如 @Grant 提到的,Powershell 可用于从存储中删除(有效禁用)证书。可以在删除之前完成导出,以便您可以将它们重新导入回商店。

要导出并从商店中删除:

Add-Type -AssemblyName System.Security

$exportPath = 'c:\temp\certexport'

$certStore = New-Object System.Security.Cryptography.X509Certificates.X509Store -ArgumentList 'Root', 'LocalMachine'

$certStore.Open('ReadWrite')

foreach ($cert in $certStore.Certificates) {

    # Export cert to a .cer file.
    $certPath = Join-Path -Path $exportPath -ChildPath "$($cert.Thumbprint).cer"
    [System.IO.File]::WriteAllBytes($certPath, $cert.Export('Cert'))

    # Remove the cert from the store.
    $certStore.Remove($cert)

}
$certStore.Close()
Run Code Online (Sandbox Code Playgroud)

要将它们重新导入回商店:

Add-Type -AssemblyName System.Security

$exportPath = 'c:\temp\certexport'

$certStore = New-Object System.Security.Cryptography.X509Certificates.X509Store -ArgumentList 'Root', 'LocalMachine'

$certStore.Open('ReadWrite')

Get-ChildItem -Path $exportPath -Filter *.cer | ForEach-Object {

    $cert = New-Object -TypeName System.Security.Cryptography.X509Certificates.X509Certificate($_.FullName)

    $certStore.Add($cert)
}
$certStore.Close()
Run Code Online (Sandbox Code Playgroud)