SignedCms.CheckSignature 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
验证已签名 CMS/PKCS #7 消息上的数字签名。
重载
| 名称 | 说明 |
|---|---|
| CheckSignature(Boolean) |
该方法 CheckSignature(Boolean) 验证已签名 CMS/PKCS #7 消息上的数字签名,并根据需要验证签名者的证书。 |
| CheckSignature(X509Certificate2Collection, Boolean) |
该方法 CheckSignature(X509Certificate2Collection, Boolean) 使用指定的证书集合验证已签名 CMS/PKCS #7 消息上的数字签名,并根据需要验证签名者的证书。 |
CheckSignature(Boolean)
- Source:
- SignedCms.cs
- Source:
- SignedCms.cs
- Source:
- SignedCms.cs
- Source:
- SignedCms.cs
- Source:
- SignedCms.cs
- Source:
- SignedCms.cs
- Source:
- SignedCms.cs
- Source:
- 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)
- Source:
- SignedCms.cs
- Source:
- SignedCms.cs
- Source:
- SignedCms.cs
- Source:
- SignedCms.cs
- Source:
- SignedCms.cs
- Source:
- SignedCms.cs
- Source:
- SignedCms.cs
- Source:
- 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 消息上的所有签名,包括反签名。 如果消息中包含有签名属性,则还会验证这些属性。 如果选择此选项来验证证书,则会验证证书链的整个包含部分。
如果数字签名的验证失败或未满足任何验证要求,此方法将引发异常。