CmsSigner 构造函数

定义

初始化 CmsSigner 类的新实例。

重载

CmsSigner()

使用默认值初始化 CmsSigner 类的新实例。

CmsSigner(CspParameters)
已过时。

基于保留的密钥来初始化 CmsSigner 类的新实例。

CmsSigner(SubjectIdentifierType)

使用指定的使用者标识符类型来初始化 CmsSigner 类的新实例。

CmsSigner(X509Certificate2)

使用指定的签名者证书来初始化 CmsSigner 类的新实例。

CmsSigner(SubjectIdentifierType, X509Certificate2)

使用指定的签名者证书和使用者标识符类型来初始化 CmsSigner 类的新实例。

CmsSigner(SubjectIdentifierType, X509Certificate2, AsymmetricAlgorithm)

使用指定的签名者证书、使用者标识符类型和私钥对象来初始化 CmsSigner 类的新实例。

CmsSigner(SubjectIdentifierType, X509Certificate2, RSA, RSASignaturePadding)

使用指定的签名者证书、使用者标识符类型、私钥对象和 RSA 签名填充初始化 CmsSigner 类的新实例。

CmsSigner()

使用默认值初始化 CmsSigner 类的新实例。

public:
 CmsSigner();
public CmsSigner ();
Public Sub New ()

注解

此构造函数生成以下默认属性值:

properties 默认值
SignerIdentifierType SubjectIdentifierType.IssuerAndSerialNumber
DigestAlgorithm 2.16.840.1.101.3.4.2.1 (SHA-256)
IncludeOption X509IncludeOption.ExcludeRoot

适用于

CmsSigner(CspParameters)

注意

CmsSigner(CspParameters) is obsolete and is not supported. Use an alternative constructor instead.

基于保留的密钥来初始化 CmsSigner 类的新实例。

public:
 CmsSigner(System::Security::Cryptography::CspParameters ^ parameters);
public CmsSigner (System.Security.Cryptography.CspParameters parameters);
[System.Obsolete("CmsSigner(CspParameters) is obsolete and is not supported. Use an alternative constructor instead.", DiagnosticId="SYSLIB0034", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public CmsSigner (System.Security.Cryptography.CspParameters parameters);
new System.Security.Cryptography.Pkcs.CmsSigner : System.Security.Cryptography.CspParameters -> System.Security.Cryptography.Pkcs.CmsSigner
[<System.Obsolete("CmsSigner(CspParameters) is obsolete and is not supported. Use an alternative constructor instead.", DiagnosticId="SYSLIB0034", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Security.Cryptography.Pkcs.CmsSigner : System.Security.Cryptography.CspParameters -> System.Security.Cryptography.Pkcs.CmsSigner
Public Sub New (parameters As CspParameters)

参数

parameters
CspParameters

用于描述要使用的签名密钥的 CSP 参数。

属性

例外

仅限 .NET Core 和 .NET 5 及更高版本:在所有情况下。

注解

此构造函数生成以下默认属性值:

properties 默认值
SignerIdentifierType SubjectIdentifierType.SubjectKeyIdentifier
DigestAlgorithm 2.16.840.1.101.3.4.2.1 (SHA-256)
IncludeOption X509IncludeOption.None

重要

此方法仅在.NET Framework上受支持。 它在 .NET Core 上使用会引发一个 PlatformNotSupportedException

适用于

CmsSigner(SubjectIdentifierType)

使用指定的使用者标识符类型来初始化 CmsSigner 类的新实例。

public:
 CmsSigner(System::Security::Cryptography::Pkcs::SubjectIdentifierType signerIdentifierType);
public CmsSigner (System.Security.Cryptography.Pkcs.SubjectIdentifierType signerIdentifierType);
new System.Security.Cryptography.Pkcs.CmsSigner : System.Security.Cryptography.Pkcs.SubjectIdentifierType -> System.Security.Cryptography.Pkcs.CmsSigner
Public Sub New (signerIdentifierType As SubjectIdentifierType)

参数

signerIdentifierType
SubjectIdentifierType

用于标识所使用的签名证书的方案。

注解

此构造函数生成以下默认属性值:

properties 默认值
DigestAlgorithm 2.16.840.1.101.3.4.2.1 (SHA-256)
IncludeOption X509IncludeOption.None如果为 ,则SignerIdentifierTypeSubjectIdentifierType.NoSignature

X509IncludeOption.ExcludeRoot 否则

适用于

CmsSigner(X509Certificate2)

使用指定的签名者证书来初始化 CmsSigner 类的新实例。

public:
 CmsSigner(System::Security::Cryptography::X509Certificates::X509Certificate2 ^ certificate);
public CmsSigner (System.Security.Cryptography.X509Certificates.X509Certificate2 certificate);
public CmsSigner (System.Security.Cryptography.X509Certificates.X509Certificate2? certificate);
new System.Security.Cryptography.Pkcs.CmsSigner : System.Security.Cryptography.X509Certificates.X509Certificate2 -> System.Security.Cryptography.Pkcs.CmsSigner
Public Sub New (certificate As X509Certificate2)

参数

certificate
X509Certificate2

私钥将用于对消息进行签名的证书。

注解

此构造函数生成以下默认属性值:

properties 默认值
SignerIdentifierType SubjectIdentifierType.IssuerAndSerialNumber
DigestAlgorithm 2.16.840.1.101.3.4.2.1 (SHA-256)
IncludeOption X509IncludeOption.ExcludeRoot

参数指定的 certificate 签名证书未检查输入的有效性。 若要在向此构造函数提供证书之前验证证书,请使用 X509Chain.Build 该方法。

适用于

CmsSigner(SubjectIdentifierType, X509Certificate2)

使用指定的签名者证书和使用者标识符类型来初始化 CmsSigner 类的新实例。

public:
 CmsSigner(System::Security::Cryptography::Pkcs::SubjectIdentifierType signerIdentifierType, System::Security::Cryptography::X509Certificates::X509Certificate2 ^ certificate);
public CmsSigner (System.Security.Cryptography.Pkcs.SubjectIdentifierType signerIdentifierType, System.Security.Cryptography.X509Certificates.X509Certificate2 certificate);
public CmsSigner (System.Security.Cryptography.Pkcs.SubjectIdentifierType signerIdentifierType, System.Security.Cryptography.X509Certificates.X509Certificate2? certificate);
new System.Security.Cryptography.Pkcs.CmsSigner : System.Security.Cryptography.Pkcs.SubjectIdentifierType * System.Security.Cryptography.X509Certificates.X509Certificate2 -> System.Security.Cryptography.Pkcs.CmsSigner
Public Sub New (signerIdentifierType As SubjectIdentifierType, certificate As X509Certificate2)

参数

signerIdentifierType
SubjectIdentifierType

用于标识所使用的签名证书的方案。

certificate
X509Certificate2

私钥将用于对消息进行签名的证书。

注解

此构造函数生成以下默认属性值:

properties 默认值
DigestAlgorithm 2.16.840.1.101.3.4.2.1 (SHA-256)
IncludeOption X509IncludeOption.None如果为 ,则SignerIdentifierTypeSubjectIdentifierType.NoSignature

X509IncludeOption.ExcludeRoot 否则

参数指定的 certificate 签名证书未检查输入的有效性。 若要在向此构造函数提供证书之前验证证书,请使用 X509Chain.Build 该方法。

适用于

CmsSigner(SubjectIdentifierType, X509Certificate2, AsymmetricAlgorithm)

使用指定的签名者证书、使用者标识符类型和私钥对象来初始化 CmsSigner 类的新实例。

public:
 CmsSigner(System::Security::Cryptography::Pkcs::SubjectIdentifierType signerIdentifierType, System::Security::Cryptography::X509Certificates::X509Certificate2 ^ certificate, System::Security::Cryptography::AsymmetricAlgorithm ^ privateKey);
public CmsSigner (System.Security.Cryptography.Pkcs.SubjectIdentifierType signerIdentifierType, System.Security.Cryptography.X509Certificates.X509Certificate2 certificate, System.Security.Cryptography.AsymmetricAlgorithm privateKey);
public CmsSigner (System.Security.Cryptography.Pkcs.SubjectIdentifierType signerIdentifierType, System.Security.Cryptography.X509Certificates.X509Certificate2? certificate, System.Security.Cryptography.AsymmetricAlgorithm? privateKey);
new System.Security.Cryptography.Pkcs.CmsSigner : System.Security.Cryptography.Pkcs.SubjectIdentifierType * System.Security.Cryptography.X509Certificates.X509Certificate2 * System.Security.Cryptography.AsymmetricAlgorithm -> System.Security.Cryptography.Pkcs.CmsSigner
Public Sub New (signerIdentifierType As SubjectIdentifierType, certificate As X509Certificate2, privateKey As AsymmetricAlgorithm)

参数

signerIdentifierType
SubjectIdentifierType

枚举值之一,指定用于标识所使用的签名证书的方案。

certificate
X509Certificate2

私钥将用于对消息进行签名的证书。

privateKey
AsymmetricAlgorithm

对消息进行签名时要使用的私钥对象。

注解

此构造函数生成以下默认属性值:

properties 默认值
DigestAlgorithm 2.16.840.1.101.3.4.2.1 (SHA-256)
IncludeOption X509IncludeOption.None如果为 ,则SignerIdentifierTypeSubjectIdentifierType.NoSignature

X509IncludeOption.ExcludeRoot 否则

参数指定的 certificate 签名证书未检查输入的有效性。 若要在向此构造函数提供证书之前验证证书,请使用 X509Chain.Build 该方法。

此构造函数不验证参数是否 privateKey 与公钥 certificate相对应。 如果密钥不匹配,则SignedCms类和ComputeCounterSignature(CmsSigner)方法会在签名过程中引发。CryptographicException

适用于

CmsSigner(SubjectIdentifierType, X509Certificate2, RSA, RSASignaturePadding)

使用指定的签名者证书、使用者标识符类型、私钥对象和 RSA 签名填充初始化 CmsSigner 类的新实例。

public:
 CmsSigner(System::Security::Cryptography::Pkcs::SubjectIdentifierType signerIdentifierType, System::Security::Cryptography::X509Certificates::X509Certificate2 ^ certificate, System::Security::Cryptography::RSA ^ privateKey, System::Security::Cryptography::RSASignaturePadding ^ signaturePadding);
public CmsSigner (System.Security.Cryptography.Pkcs.SubjectIdentifierType signerIdentifierType, System.Security.Cryptography.X509Certificates.X509Certificate2? certificate, System.Security.Cryptography.RSA? privateKey, System.Security.Cryptography.RSASignaturePadding? signaturePadding);
new System.Security.Cryptography.Pkcs.CmsSigner : System.Security.Cryptography.Pkcs.SubjectIdentifierType * System.Security.Cryptography.X509Certificates.X509Certificate2 * System.Security.Cryptography.RSA * System.Security.Cryptography.RSASignaturePadding -> System.Security.Cryptography.Pkcs.CmsSigner
Public Sub New (signerIdentifierType As SubjectIdentifierType, certificate As X509Certificate2, privateKey As RSA, signaturePadding As RSASignaturePadding)

参数

signerIdentifierType
SubjectIdentifierType

枚举值之一,指定用于标识所使用的签名证书的方案。

certificate
X509Certificate2

私钥将用于对消息进行签名的证书。

privateKey
RSA

对消息进行签名时要使用的私钥对象。

signaturePadding
RSASignaturePadding

要使用的 RSA 签名填充。

适用于