2017-07-19 61 views
-3

我想要一個可以在服務器上運行的工具,該工具將從已安裝的SSL證書中提取並返回指定的屬性。我特別感興趣的是「發行人」和「指紋」屬性。我知道我可以簡單地打開證書的屬性對話框並複製這些對話框,然後將它們粘貼到我的應用程序中,但是爲了避免其他人在多個網站上執行此操作時可能出現的易於出錯的手動過程,我想要一個工具或腳本我可以調用它只會從指定的證書返回指定屬性的值。我很好,如果我需要分別打電話給每個所需的財產。交鑰匙越多越好。有什麼建議嗎?如何提取SSL證書屬性

+3

這是可行的。給它一個去,並問你是否有一個_specific_問題。將您的問題標題以添加到Google的「PowerShell」字面複製;你不應該比第一對結果更進一步。 – gms0ulman

回答

0

你想要做這樣的事情:

Get-ChildItem Cert:\LocalMachine\Root\ | Select Issuer,Thumbprint 

這裏是屬性的列表,你可以很容易地從System.Security.Cryptography.X509Certificates.X509Certificate2對象(普通證書)獲得。

Name     MemberType  Definition                                                     
----     ----------  ----------                                                     
Archived    Property  bool Archived {get;set;}                                                  
Extensions   Property  System.Security.Cryptography.X509Certificates.X509ExtensionCollection Extensions {get;}                                  
FriendlyName   Property  string FriendlyName {get;set;}                                                
Handle    Property  System.IntPtr Handle {get;}                                                 
HasPrivateKey  Property  bool HasPrivateKey {get;}                                                  
Issuer    Property  string Issuer {get;}                                                   
IssuerName   Property  System.Security.Cryptography.X509Certificates.X500DistinguishedName IssuerName {get;}                                   
NotAfter    Property  datetime NotAfter {get;}                                                  
NotBefore   Property  datetime NotBefore {get;}                                                  
PrivateKey   Property  System.Security.Cryptography.AsymmetricAlgorithm PrivateKey {get;set;}                                      
PublicKey   Property  System.Security.Cryptography.X509Certificates.PublicKey PublicKey {get;}                                      
RawData    Property  byte[] RawData {get;}                                                   
SerialNumber   Property  string SerialNumber {get;}                                                 
SignatureAlgorithm Property  System.Security.Cryptography.Oid SignatureAlgorithm {get;}                                         
Subject    Property  string Subject {get;}                                                   
SubjectName   Property  System.Security.Cryptography.X509Certificates.X500DistinguishedName SubjectName {get;}                                  
Thumbprint   Property  string Thumbprint {get;}                                                  
Version    Property  int Version {get;}                                                   
DnsNameList   ScriptProperty System.Object DnsNameList {get=,(new-object Microsoft.Powershell.Commands.DnsNameProperty -argumentlist $this).DnsNameList;;}                         
EnhancedKeyUsageList ScriptProperty System.Object EnhancedKeyUsageList {get=,(new-object Microsoft.Powershell.Commands.EnhancedKeyUsageProperty -argumentlist $this).EnhancedKeyUsageList;;}                  
SendAsTrustedIssuer ScriptProperty System.Object SendAsTrustedIssuer {get=[Microsoft.Powershell.Commands.SendAsTrustedIssuerProperty]::ReadSendAsTrustedIssuerProperty($this);set=$sendAsTrustedIssuer = $args[0]...