如果我使用“System.Security.Cryptography.X509Certificates”,是否可以从 powershell 脚本中的证书检索颁发者指纹?
我有这个 powershell 脚本,可以获取远程服务器上“我的”存储中的所有证书,然后将其输出到格式表。我希望能够知道使用相同脚本的发行者指纹是什么。
Param(
[parameter(
Mandatory=$true)]
[String]$CSVFile
)
Set-ExecutionPolicy RemoteSigned
$Serveurs = import-csv $CSVFile
$Nom = $Serveurs.Nom
Foreach ($Serveur in $Serveurs){
$x509store = new-object System.Security.Cryptography.X509Certificates.X509Store("\\$($Serveur.Nom)\My","LocalMachine")
$x509store.Open('ReadOnly')
$x509store.Certificates | Format-Table -Property FriendlyName,NotAfter,Thumbprint,Issuer,Subject
}
谢谢!
最佳答案
我建议使用 powershell 为您的证书存储提供的 psdrive。
Get-ChildItem -Path Cert:\LocalMachine\My |
Format-Table -Property FriendlyName,NotAfter,Thumbprint,Issuer,Subject
更新:
我没有注意到这是针对远程机器的。您可以在 Invoke-Command 中敲击该 cmd。
Invoke-Command -ComputerName "Computer1","Computer2",... -ScriptBlock {Get-ChildItem -Path Cert:\LocalMachine\My}
关于ssl - 使用 "System.Security.Cryptography.X509Certificates"从证书中检索颁发者指纹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23431484/