Pular para o conteúdo principal

CadesSigner

Namespace: Lacuna.Pki.Cades
Assembly: Lacuna.Pki
Class

Class for creating CAdES signatures

public class CadesSigner : IDisposable

Hierarquia: objectCadesSigner

Construtores

CadesSigner()

public CadesSigner()

Propriedades

ValidationResults

public ValidationResults ValidationResults { get; }

Retorno

ValidationResults


Warnings

public List<string> Warnings { get; }

Retorno

List<string>


Métodos

AddAttributeCertificate(AttributeCertificate)

Adds attribute certificates in the signed attributes

public void AddAttributeCertificate(AttributeCertificate attributeCertificate)

Parâmetros

NomeTipoDescrição
attributeCertificateAttributeCertificateCertificate attribute

AddAttributeCertificate(IEnumerable<AttributeCertificate>)

Adds attribute certificates in the signed attributes

public void AddAttributeCertificate(IEnumerable<AttributeCertificate> attributeCertificate)

Parâmetros

NomeTipoDescrição
attributeCertificateIEnumerable<AttributeCertificate>Certificate attribute

ComputeSignature()

Computes the CAdES signature elements. Call after all parameters set

public void ComputeSignature()

Dispose()

Disposes streams used

public void Dispose()

GenerateToSignBytes(out SignatureAlgorithm)

Generates the bytes to be signed

public byte[] GenerateToSignBytes(out SignatureAlgorithm signatureAlg)

Parâmetros

NomeTipoDescrição
signatureAlgSignatureAlgorithmSignature algorithm to be used

Retorno

byte[] — To sign bytes


GetSignature()

Gets the completed signature content

public byte[] GetSignature()

Retorno

byte[]


GetSignatureFinisher()

Gets the signature finisher. Used in a three-step signature

public CadesSignatureFinisher GetSignatureFinisher()

Retorno

CadesSignatureFinisher — Signature finisher. An element that will handle the timestamps and revocation elements of the signature


SetCertificateValidationConfigurator(Action<CertificateValidationOptions>)

Sets an action for configuring the signer certificate validation

public void SetCertificateValidationConfigurator(Action<CertificateValidationOptions> configureCertificateValidation)

Parâmetros

NomeTipoDescrição
configureCertificateValidationAction<CertificateValidationOptions>

SetCommitmentType(CommitmentType)

Sets the signer commitment type signed attribute

public void SetCommitmentType(CommitmentType commitmentType)

Parâmetros

NomeTipoDescrição
commitmentTypeCommitmentType

SetContentType(CmsContentType)

Sets the encapsulated content type of the SignedData. Note: only use this if you are not signing a Data type

public void SetContentType(CmsContentType contentType)

Parâmetros

NomeTipoDescrição
contentTypeCmsContentType

SetCrlStore(IReferencedCrlStore)

Sets a trusted CRL store indexed by CRL digest values.

public void SetCrlStore(IReferencedCrlStore crlStore)

Parâmetros

NomeTipoDescrição
crlStoreIReferencedCrlStoreCRL store

SetDataDigestToSign(DigestAlgorithm, byte[])

Sets the message digest that is going to be signed. Using this method instead of SetDataToSign will mandatorily result in a detached signature, without encapsulated content.

public void SetDataDigestToSign(DigestAlgorithm digestAlgorithm, byte[] digestValue)

Parâmetros

NomeTipoDescrição
digestAlgorithmDigestAlgorithm
digestValuebyte[]

SetDataToSign(byte[])

Sets the data content that is going to be signed

public void SetDataToSign(byte[] data)

Parâmetros

NomeTipoDescrição
databyte[]The data content bytes to be signed

SetDataToSign(Stream)

Sets the data that is going to be signed

public void SetDataToSign(Stream stream)

Parâmetros

NomeTipoDescrição
streamStream

SetEncapsulatedContent(bool)

Wheter or not to include the encapsulated content in the signature. If not set, default value is true

public void SetEncapsulatedContent(bool includeEncapsulatedContent)

Parâmetros

NomeTipoDescrição
includeEncapsulatedContentbool

SetFinishSignature(bool)

Sets if the signature will be closed after the signing process ends. Default is true. Set false if it is a three-step signature

public void SetFinishSignature(bool finishSignature)

Parâmetros

NomeTipoDescrição
finishSignaturebool

SetPolicy(CadesPolicySpec)

Sets the signature policy specification

public void SetPolicy(CadesPolicySpec policy)

Parâmetros

NomeTipoDescrição
policyCadesPolicySpecPolicy specification

SetPolicy(ICadesPolicyMapper)

Sets a policy specification mapper

public void SetPolicy(ICadesPolicyMapper policyMapper)

Parâmetros

NomeTipoDescrição
policyMapperICadesPolicyMapperPolicy mapper

SetPrecomputedSignature(byte[], byte[])

Sets the signed bytes from the client. Used in a two-step signature

public void SetPrecomputedSignature(byte[] signature, byte[] toSignBytes)

Parâmetros

NomeTipoDescrição
signaturebyte[]Signed bytes
toSignBytesbyte[]To sign bytes used in the signing process

SetPrecomputedSignature(byte[])

Sets the signed bytes from the client. Used in a two-step signature

public void SetPrecomputedSignature(byte[] signature)

Parâmetros

NomeTipoDescrição
signaturebyte[]Signed bytes

SetSignatureToCoSign(byte[])

Sets the signature to create a co-signature

public bool SetSignatureToCoSign(byte[] signature)

Parâmetros

NomeTipoDescrição
signaturebyte[]Signature content bytes

Retorno

bool


SetSignatureToCoSign(Stream)

Sets the signature to create a co-signature

public bool SetSignatureToCoSign(Stream stream)

Parâmetros

NomeTipoDescrição
streamStreamSignature stream

Retorno

bool


SetSigningCertificate(PKCertificate)

Sets the signing certificate. Used in a two-step signature

public void SetSigningCertificate(PKCertificate certificate)

Parâmetros

NomeTipoDescrição
certificatePKCertificateCertificate

SetSigningCertificate(PKCertificateWithKey)

Sets the signing certificate with private key. Used in a one-step signature

public void SetSigningCertificate(PKCertificateWithKey certWithKey)

Parâmetros

NomeTipoDescrição
certWithKeyPKCertificateWithKeyCertificate with private key

SetSigningDescription(string)

Sets a custom text describing the signing operation. If set, it will be inlcuded as a signingDescription signed attribute

public void SetSigningDescription(string description)

Parâmetros

NomeTipoDescrição
descriptionstring

SetTimestampRequester(ITimestampRequester)

Sets a timestamp requester. Must be set if the policy specification requires any type of timestamp attribute

public void SetTimestampRequester(ITimestampRequester tsRequester)

Parâmetros

NomeTipoDescrição
tsRequesterITimestampRequesterTimestamp requester

VerifyParameters(bool)

Verifies if CadesSigner necessary parameters are set. If not, throws Exception.

public void VerifyParameters(bool computingSignature = false)

Parâmetros

NomeTipoDescrição
computingSignatureboolWhether or not you will call the ComputeSignature() method to complete the siganture process in this step.

WriteSignature(Stream)

Writes the completed signature content to a stream

public void WriteSignature(Stream stream)

Parâmetros

NomeTipoDescrição
streamStreamStream

Membros herdados

ToString(), Equals(object), Equals(object, object), ReferenceEquals(object, object), GetHashCode(), GetType(), MemberwiseClone()