SignedCms.CheckSignature 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
驗證已簽署的 CMS/PKCS #7 訊息的數位簽章。
多載
| 名稱 | Description |
|---|---|
| CheckSignature(Boolean) |
此 CheckSignature(Boolean) 方法驗證已簽署的 CMS/PKCS #7 訊息上的數位簽章,並可選擇性驗證簽署者的憑證。 |
| CheckSignature(X509Certificate2Collection, Boolean) |
此 CheckSignature(X509Certificate2Collection, Boolean) 方法透過指定的憑證集合驗證已簽署的 CMS/PKCS #7 訊息上的數位簽章,並可選擇性地驗證簽署者的憑證。 |
CheckSignature(Boolean)
- 來源:
- SignedCms.cs
- 來源:
- SignedCms.cs
- 來源:
- SignedCms.cs
- 來源:
- SignedCms.cs
- 來源:
- SignedCms.cs
- 來源:
- SignedCms.cs
- 來源:
- SignedCms.cs
- 來源:
- SignedCms.cs
- 來源:
- SignedCms.cs
此 CheckSignature(Boolean) 方法驗證已簽署的 CMS/PKCS #7 訊息上的數位簽章,並可選擇性驗證簽署者的憑證。
public:
void CheckSignature(bool verifySignatureOnly);
public void CheckSignature(bool verifySignatureOnly);
member this.CheckSignature : bool -> unit
Public Sub CheckSignature (verifySignatureOnly As Boolean)
參數
- verifySignatureOnly
- Boolean
此 Boolean 值指定是否僅驗證數位簽章,且未驗證簽署者憑證。
若 verifySignatureOnly , true則僅驗證數位簽章。 如果是 false,則數位簽章會被驗證,簽署者的憑證會被驗證,憑證的目的也會被驗證。 若憑證無金鑰使用,或金鑰使用支援數位簽章或不可否認,則該憑證的用途被視為有效。
例外狀況
一個空引用被傳遞給一個不接受該參數為有效參數的方法。
密碼學操作無法完成。
某個方法呼叫對物件目前狀態而言無效。
範例
以下範例展示了驗證訊息簽名CheckSignature(Boolean)所需步驟中的位置SignedCms。 在此範例中,訊息內容並非分離。 訊息內容包含在訊息中 SignedCms 。
// Create a new, nondetached SignedCms message.
SignedCms signedCms = new SignedCms();
// encodedMessage is the encoded message received from
// the sender.
signedCms.Decode(encodedMessage);
// Verify the signature without validating the
// certificate.
signedCms.CheckSignature(true);
' Create a new, nondetached SignedCms message.
Dim signedCms As New SignedCms()
' encodedMessage is the encoded message received from
' the sender.
signedCms.Decode(encodedMessage)
' Verify the signature without validating the
' certificate.
signedCms.CheckSignature(True)
以下範例展示了驗證訊息簽名CheckSignature(Boolean)所需步驟中的位置SignedCms。 在此範例中,訊息內容是分離的,因此訊息內容必須獨立 SignedCms 於訊息本身進行驗證。
// Create a ContentInfo object from the inner content obtained
// independently from encodedMessage.
ContentInfo contentInfo = new ContentInfo(innerContent);
// Create a new, detached SignedCms message.
SignedCms signedCms = new SignedCms(contentInfo, true);
// encodedMessage is the encoded message received from
// the sender.
signedCms.Decode(encodedMessage);
// Verify the signature without validating the
// certificate.
signedCms.CheckSignature(true);
' Create a ContentInfo object from the inner content obtained
' independently from encodedMessage.
Dim contentInfo As New ContentInfo(innerContent)
' Create a new, detached SignedCms message.
Dim signedCms As New SignedCms(contentInfo, True)
' encodedMessage is the encoded message received from
' the sender.
signedCms.Decode(encodedMessage)
' Verify the signature without validating the
' certificate.
signedCms.CheckSignature(True)
備註
此方法驗證 CMS/PKCS #7 訊息上的所有簽章,包括反簽。 若訊息中包含有符號屬性,這些屬性也會被驗證。 若選擇驗證憑證,則憑證鏈中包含的整個部分都會被驗證。
此方法若數位簽章驗證失敗或未符合任何驗證要求,會拋出例外。
適用於
CheckSignature(X509Certificate2Collection, Boolean)
- 來源:
- SignedCms.cs
- 來源:
- SignedCms.cs
- 來源:
- SignedCms.cs
- 來源:
- SignedCms.cs
- 來源:
- SignedCms.cs
- 來源:
- SignedCms.cs
- 來源:
- SignedCms.cs
- 來源:
- SignedCms.cs
- 來源:
- SignedCms.cs
此 CheckSignature(X509Certificate2Collection, Boolean) 方法透過指定的憑證集合驗證已簽署的 CMS/PKCS #7 訊息上的數位簽章,並可選擇性地驗證簽署者的憑證。
public:
void CheckSignature(System::Security::Cryptography::X509Certificates::X509Certificate2Collection ^ extraStore, bool verifySignatureOnly);
public void CheckSignature(System.Security.Cryptography.X509Certificates.X509Certificate2Collection extraStore, bool verifySignatureOnly);
member this.CheckSignature : System.Security.Cryptography.X509Certificates.X509Certificate2Collection * bool -> unit
Public Sub CheckSignature (extraStore As X509Certificate2Collection, verifySignatureOnly As Boolean)
參數
- extraStore
- X509Certificate2Collection
一個 X509Certificate2Collection 可以用來驗證憑證鏈的物件。 若不需使用額外憑證來驗證憑證鏈,請使用 CheckSignature(Boolean)CheckSignature(X509Certificate2Collection, Boolean)代替 。
- verifySignatureOnly
- Boolean
此 Boolean 值指定是否僅驗證數位簽章,且未驗證簽署者憑證。
若 verifySignatureOnly , true則僅驗證數位簽章。 如果是 false,則數位簽章會被驗證,簽署者的憑證會被驗證,憑證的目的也會被驗證。 若憑證無金鑰使用,或金鑰使用支援數位簽章或不可否認,則該憑證的用途被視為有效。
例外狀況
一個空引用被傳遞給一個不接受該參數為有效參數的方法。
密碼學操作無法完成。
某個方法呼叫對物件目前狀態而言無效。
備註
此方法驗證 CMS/PKCS #7 訊息上的所有簽章,包括反簽。 若訊息中包含有符號屬性,這些屬性也會被驗證。 若選擇驗證憑證,則憑證鏈中包含的整個部分都會被驗證。
此方法若數位簽章驗證失敗或未符合任何驗證要求,會拋出例外。