SignedCms.ComputeSignature Método

Definición

Crea una firma y la agrega al mensaje CMS o PKCS #7.

Sobrecargas

ComputeSignature(CmsSigner, Boolean)

Crea una firma utilizando el firmante especificado y agrega la firma al mensaje CMS o PKCS #7.

ComputeSignature()

Crea una firma y la agrega al mensaje CMS o PKCS #7.

ComputeSignature(CmsSigner)

Crea una firma utilizando el firmante especificado y agrega la firma al mensaje CMS o PKCS #7.

ComputeSignature(CmsSigner, Boolean)

Source:
SignedCms.cs
Source:
SignedCms.cs
Source:
SignedCms.cs

Crea una firma utilizando el firmante especificado y agrega la firma al mensaje CMS o PKCS #7.

public:
 void ComputeSignature(System::Security::Cryptography::Pkcs::CmsSigner ^ signer, bool silent);
public void ComputeSignature (System.Security.Cryptography.Pkcs.CmsSigner signer, bool silent);
member this.ComputeSignature : System.Security.Cryptography.Pkcs.CmsSigner * bool -> unit
Public Sub ComputeSignature (signer As CmsSigner, silent As Boolean)

Parámetros

signer
CmsSigner

Objeto CmsSigner que representa el firmante.

silent
Boolean

Solo .NET Core y .NET 5+: true para solicitar claves de apertura con avisos de PIN deshabilitados, donde se admite; de lo contrario, false. En .NET Framework, este parámetro no se usa y siempre se muestra una solicitud de PIN, si se requiere.

Excepciones

signer es null.

No se pudo finalizar una operación criptográfica.

Solo .NET Framework: no se ha especificado ningún certificado de firma.

Solo .NET Core y .NET 5+: no se especifica un certificado de firma.

Comentarios

Solo .NET Core: el silent parámetro no tiene ningún efecto si el CmsSigner.PrivateKey valor no es NULL. El valor proporcionado controla si la firma muestra o no un símbolo del sistema de PIN. Incluso cuando la PrivateKey propiedad es null y el silent parámetro se establece trueen , algunas combinaciones de opciones del sistema operativo y del firmante todavía pueden dar lugar a un símbolo del sistema operativo.

Se requieren los siguientes permisos para mostrar la interfaz de usuario en .NET Framework:

Se requieren los siguientes permisos para acceder a la clave de firma en .NET Framework:

Se aplica a

ComputeSignature()

Source:
SignedCms.cs
Source:
SignedCms.cs
Source:
SignedCms.cs

Crea una firma y la agrega al mensaje CMS o PKCS #7.

public:
 void ComputeSignature();
public void ComputeSignature ();
member this.ComputeSignature : unit -> unit
Public Sub ComputeSignature ()

Excepciones

.NET Framework (todas las versiones) y .NET Core 3.0 y versiones posteriores: el certificado de destinatario no se ha especificado.

.NET Core 2.2 y versiones anterior: no se ha proporcionado ningún certificado de firmante.

Comentarios

Este método se realiza correctamente si SubjectIdentifierType.NoSignature se proporcionó como argumento signerIdentifierType de una de las SignedCms sobrecargas del constructor. De lo contrario, produce una excepción.

Se requieren los siguientes permisos para acceder a la clave de firma en .NET Framework:

Se aplica a

ComputeSignature(CmsSigner)

Source:
SignedCms.cs
Source:
SignedCms.cs
Source:
SignedCms.cs

Crea una firma utilizando el firmante especificado y agrega la firma al mensaje CMS o PKCS #7.

public:
 void ComputeSignature(System::Security::Cryptography::Pkcs::CmsSigner ^ signer);
public void ComputeSignature (System.Security.Cryptography.Pkcs.CmsSigner signer);
member this.ComputeSignature : System.Security.Cryptography.Pkcs.CmsSigner -> unit
Public Sub ComputeSignature (signer As CmsSigner)

Parámetros

signer
CmsSigner

Objeto CmsSigner que representa el firmante.

Excepciones

Se ha pasado una referencia nula a un método que no la acepta como argumento válido.

No se pudo finalizar una operación criptográfica.

Ejemplos

En el ejemplo siguiente se muestran los pasos para calcular una firma en un SignedCms mensaje con contenido de mensaje que no está desasociado. En este caso, el contenido del mensaje se incluye en el SignedCms mensaje.

// The dataToSign byte array holds the data to be signed.
ContentInfo contentInfo = new ContentInfo(dataToSign);

// Create a new, nondetached SignedCms message.
SignedCms signedCms = new SignedCms(contentInfo);

// Sign the message.
signedCms.ComputeSignature();

// Encode the message.
byte[] myCmsMessage = signedCms.Encode();

// The signed CMS/PKCS #7 message is ready to send.
// The original content is included in this byte array.
' The dataToSign byte array holds the data to be signed.
Dim contentInfo As New ContentInfo(dataToSign)

' Create a new, nondetached SignedCms message.
Dim signedCms As New SignedCms(contentInfo)

' Sign the message.
signedCms.ComputeSignature()

' Encode the message.
Dim myCmsMessage As Byte() = signedCms.Encode()

' The signed CMS/PKCS #7 message is ready to send.
' The original content is included in this byte array.

En el ejemplo siguiente se muestran los pasos para calcular una firma en un SignedCms mensaje con contenido de mensaje desasociado. En este caso, el contenido del mensaje debe comprobarse independientemente del SignedCms mensaje.

// The dataToSign byte array holds the data to be signed.
ContentInfo contentInfo = new ContentInfo(dataToSign);

// Create a new, detached SignedCms message.
SignedCms signedCms = new SignedCms(contentInfo, true);

// Sign the message.
signedCms.ComputeSignature();

// Encode the message.
byte[] myCmsMessage = signedCms.Encode();

// The signed CMS/PKCS #7 message is ready to send.
// The original content is not included in this byte array.
' The dataToSign byte array holds the data to be signed.
Dim contentInfo As New ContentInfo(dataToSign)

' Create a new, detached SignedCms message.
Dim signedCms As New SignedCms(contentInfo, True)

' Sign the message.
signedCms.ComputeSignature()

' Encode the message.
Dim myCmsMessage As Byte() = signedCms.Encode()

' The signed CMS/PKCS #7 message is ready to send.
' The original content is not included in this byte array.

Comentarios

Se requieren los siguientes permisos para acceder a la clave de firma en .NET Framework:

Se aplica a