Class CadesSigner
Class for creating CAdES signatures
Inherited Members
Namespace: Lacuna.Pki.Cades
Assembly: Lacuna.Pki.dll
Syntax
public class CadesSigner : IDisposable
Constructors
| Improve this Doc View SourceCadesSigner()
Declaration
public CadesSigner()
Properties
| Improve this Doc View SourceValidationResults
Declaration
public ValidationResults ValidationResults { get; }
Property Value
| Type | Description |
|---|---|
| ValidationResults |
Warnings
Declaration
public List<string> Warnings { get; }
Property Value
| Type | Description |
|---|---|
| List<String> |
Methods
| Improve this Doc View SourceAddAttributeCertificate(AttributeCertificate)
Adds attribute certificates in the signed attributes
Declaration
public void AddAttributeCertificate(AttributeCertificate attributeCertificate)
Parameters
| Type | Name | Description |
|---|---|---|
| AttributeCertificate | attributeCertificate | Certificate attribute |
AddAttributeCertificate(IEnumerable<AttributeCertificate>)
Adds attribute certificates in the signed attributes
Declaration
public void AddAttributeCertificate(IEnumerable<AttributeCertificate> attributeCertificate)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<AttributeCertificate> | attributeCertificate | Certificate attribute |
ComputeSignature()
Computes the CAdES signature elements. Call after all parameters set
Declaration
public void ComputeSignature()
Dispose()
Disposes streams used
Declaration
public void Dispose()
Implements
| Improve this Doc View SourceGenerateToSignBytes(out SignatureAlgorithm)
Generates the bytes to be signed
Declaration
public byte[] GenerateToSignBytes(out SignatureAlgorithm signatureAlg)
Parameters
| Type | Name | Description |
|---|---|---|
| SignatureAlgorithm | signatureAlg | Signature algorithm to be used |
Returns
| Type | Description |
|---|---|
| Byte[] | To sign bytes |
GetSignature()
Gets the completed signature content
Declaration
public byte[] GetSignature()
Returns
| Type | Description |
|---|---|
| Byte[] |
GetSignatureFinisher()
Gets the signature finisher. Used in a three-step signature
Declaration
public CadesSignatureFinisher GetSignatureFinisher()
Returns
| Type | Description |
|---|---|
| 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
Declaration
public void SetCertificateValidationConfigurator(Action<CertificateValidationOptions> configureCertificateValidation)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<CertificateValidationOptions> | configureCertificateValidation |
SetCommitmentType(CommitmentType)
Sets the signer commitment type signed attribute
Declaration
public void SetCommitmentType(CommitmentType commitmentType)
Parameters
| Type | Name | Description |
|---|---|---|
| CommitmentType | commitmentType |
SetContentType(CmsContentType)
Sets the encapsulated content type of the SignedData. Note: only use this if you are not signing a Data type
Declaration
public void SetContentType(CmsContentType contentType)
Parameters
| Type | Name | Description |
|---|---|---|
| CmsContentType | contentType |
SetCrlStore(IReferencedCrlStore)
Sets a trusted CRL store indexed by CRL digest values.
Declaration
public void SetCrlStore(IReferencedCrlStore crlStore)
Parameters
| Type | Name | Description |
|---|---|---|
| IReferencedCrlStore | crlStore | CRL 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.
Declaration
public void SetDataDigestToSign(DigestAlgorithm digestAlgorithm, byte[] digestValue)
Parameters
| Type | Name | Description |
|---|---|---|
| DigestAlgorithm | digestAlgorithm | |
| Byte[] | digestValue |
SetDataToSign(Byte[])
Sets the data content that is going to be signed
Declaration
public void SetDataToSign(byte[] data)
Parameters
| Type | Name | Description |
|---|---|---|
| Byte[] | data | The data content bytes to be signed |
SetDataToSign(Stream)
Sets the data that is going to be signed
Declaration
public void SetDataToSign(Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream |
SetEncapsulatedContent(Boolean)
Wheter or not to include the encapsulated content in the signature. If not set, default value is true
Declaration
public void SetEncapsulatedContent(bool includeEncapsulatedContent)
Parameters
| Type | Name | Description |
|---|---|---|
| Boolean | includeEncapsulatedContent |
SetFinishSignature(Boolean)
Sets if the signature will be closed after the signing process ends. Default is true. Set false if it is a three-step signature
Declaration
public void SetFinishSignature(bool finishSignature)
Parameters
| Type | Name | Description |
|---|---|---|
| Boolean | finishSignature |
SetPolicy(CadesPolicySpec)
Sets the signature policy specification
Declaration
public void SetPolicy(CadesPolicySpec policy)
Parameters
| Type | Name | Description |
|---|---|---|
| CadesPolicySpec | policy | Policy specification |
SetPolicy(ICadesPolicyMapper)
Sets a policy specification mapper
Declaration
public void SetPolicy(ICadesPolicyMapper policyMapper)
Parameters
| Type | Name | Description |
|---|---|---|
| ICadesPolicyMapper | policyMapper | Policy mapper |
SetPrecomputedSignature(Byte[])
Sets the signed bytes from the client. Used in a two-step signature
Declaration
public void SetPrecomputedSignature(byte[] signature)
Parameters
| Type | Name | Description |
|---|---|---|
| Byte[] | signature | Signed bytes |
SetPrecomputedSignature(Byte[], Byte[])
Sets the signed bytes from the client. Used in a two-step signature
Declaration
public void SetPrecomputedSignature(byte[] signature, byte[] toSignBytes)
Parameters
| Type | Name | Description |
|---|---|---|
| Byte[] | signature | Signed bytes |
| Byte[] | toSignBytes | To sign bytes used in the signing process |
SetSignatureToCoSign(Byte[])
Sets the signature to create a co-signature
Declaration
public bool SetSignatureToCoSign(byte[] signature)
Parameters
| Type | Name | Description |
|---|---|---|
| Byte[] | signature | Signature content bytes |
Returns
| Type | Description |
|---|---|
| Boolean |
SetSignatureToCoSign(Stream)
Sets the signature to create a co-signature
Declaration
public bool SetSignatureToCoSign(Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | Signature stream |
Returns
| Type | Description |
|---|---|
| Boolean |
SetSigningCertificate(PKCertificate)
Sets the signing certificate. Used in a two-step signature
Declaration
public void SetSigningCertificate(PKCertificate certificate)
Parameters
| Type | Name | Description |
|---|---|---|
| PKCertificate | certificate | Certificate |
SetSigningCertificate(PKCertificateWithKey)
Sets the signing certificate with private key. Used in a one-step signature
Declaration
public void SetSigningCertificate(PKCertificateWithKey certWithKey)
Parameters
| Type | Name | Description |
|---|---|---|
| PKCertificateWithKey | certWithKey | Certificate with private key |
SetSigningDescription(String)
Sets a custom text describing the signing operation. If set, it will be inlcuded as a signingDescription signed attribute
Declaration
public void SetSigningDescription(string description)
Parameters
| Type | Name | Description |
|---|---|---|
| String | description |
SetTimestampRequester(ITimestampRequester)
Sets a timestamp requester. Must be set if the policy specification requires any type of timestamp attribute
Declaration
public void SetTimestampRequester(ITimestampRequester tsRequester)
Parameters
| Type | Name | Description |
|---|---|---|
| ITimestampRequester | tsRequester | Timestamp requester |
VerifyParameters(Boolean)
Verifies if CadesSigner necessary parameters are set. If not, throws Exception.
Declaration
public void VerifyParameters(bool computingSignature = false)
Parameters
| Type | Name | Description |
|---|---|---|
| Boolean | computingSignature | Whether 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
Declaration
public void WriteSignature(Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | Stream |