---
title: "CadesSigner"
description: "Namespace: Lacuna.Pki.Cades"
canonical: "https://docs.lacunasoftware.com/api/Lacuna.Pki.Cades/CadesSigner"
locale: "pt-BR"
product: "PKI SDK"
last_updated: "2026-06-02"
---

# CadesSigner

**Namespace:** `Lacuna.Pki.Cades`  
**Assembly:** `Lacuna.Pki`  
_Class_

Class for creating CAdES signatures

```csharp
public class CadesSigner : IDisposable
```

**Hierarquia:** [`object`](https://learn.microsoft.com/dotnet/api/system.object) → `CadesSigner`

## Construtores

### `CadesSigner()`

```csharp
public CadesSigner()
```

---

## Propriedades

### `ValidationResults`

```csharp
public ValidationResults ValidationResults { get; }
```

**Retorno**

[`ValidationResults`](https://docs.lacunasoftware.com/api/Lacuna.Pki/ValidationResults)

---

### `Warnings`

```csharp
public List<string> Warnings { get; }
```

**Retorno**

[`List<string>`](https://learn.microsoft.com/dotnet/api/system.collections.generic.list-1)

---

## Métodos

### `AddAttributeCertificate(AttributeCertificate)`

Adds attribute certificates in the signed attributes

```csharp
public void AddAttributeCertificate(AttributeCertificate attributeCertificate)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `attributeCertificate` | [`AttributeCertificate`](https://docs.lacunasoftware.com/api/Lacuna.Pki/AttributeCertificate) | Certificate attribute |

---

### `AddAttributeCertificate(IEnumerable<AttributeCertificate>)`

Adds attribute certificates in the signed attributes

```csharp
public void AddAttributeCertificate(IEnumerable<AttributeCertificate> attributeCertificate)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `attributeCertificate` | [`IEnumerable<AttributeCertificate>`](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1) | Certificate attribute |

---

### `ComputeSignature()`

Computes the CAdES signature elements. Call after all parameters set

```csharp
public void ComputeSignature()
```

---

### `Dispose()`

Disposes streams used

```csharp
public void Dispose()
```

---

### `GenerateToSignBytes(out SignatureAlgorithm)`

Generates the bytes to be signed

```csharp
public byte[] GenerateToSignBytes(out SignatureAlgorithm signatureAlg)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `signatureAlg` | [`SignatureAlgorithm`](https://docs.lacunasoftware.com/api/Lacuna.Pki/SignatureAlgorithm) | Signature algorithm to be used |

**Retorno**

[`byte[]`](https://learn.microsoft.com/dotnet/api/system.byte) — To sign bytes

---

### `GetSignature()`

Gets the completed signature content

```csharp
public byte[] GetSignature()
```

**Retorno**

[`byte[]`](https://learn.microsoft.com/dotnet/api/system.byte)

---

### `GetSignatureFinisher()`

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

```csharp
public CadesSignatureFinisher GetSignatureFinisher()
```

**Retorno**

[`CadesSignatureFinisher`](https://docs.lacunasoftware.com/api/Lacuna.Pki.Cades/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

```csharp
public void SetCertificateValidationConfigurator(Action<CertificateValidationOptions> configureCertificateValidation)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `configureCertificateValidation` | [`Action<CertificateValidationOptions>`](https://learn.microsoft.com/dotnet/api/system.action-1) |  |

---

### `SetCommitmentType(CommitmentType)`

Sets the signer commitment type signed attribute

```csharp
public void SetCommitmentType(CommitmentType commitmentType)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `commitmentType` | [`CommitmentType`](https://docs.lacunasoftware.com/api/Lacuna.Pki/CommitmentType) |  |

---

### `SetContentType(CmsContentType)`

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

```csharp
public void SetContentType(CmsContentType contentType)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `contentType` | [`CmsContentType`](https://docs.lacunasoftware.com/api/Lacuna.Pki/CmsContentType) |  |

---

### `SetCrlStore(IReferencedCrlStore)`

Sets a trusted CRL store indexed by CRL digest values.

```csharp
public void SetCrlStore(IReferencedCrlStore crlStore)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `crlStore` | [`IReferencedCrlStore`](https://docs.lacunasoftware.com/api/Lacuna.Pki.Stores/IReferencedCrlStore) | 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.

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

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `digestAlgorithm` | [`DigestAlgorithm`](https://docs.lacunasoftware.com/api/Lacuna.Pki/DigestAlgorithm) |  |
| `digestValue` | [`byte[]`](https://learn.microsoft.com/dotnet/api/system.byte) |  |

---

### `SetDataToSign(byte[])`

Sets the data content that is going to be signed

```csharp
public void SetDataToSign(byte[] data)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `data` | [`byte[]`](https://learn.microsoft.com/dotnet/api/system.byte) | The data content bytes to be signed |

---

### `SetDataToSign(Stream)`

Sets the data that is going to be signed

```csharp
public void SetDataToSign(Stream stream)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `stream` | [`Stream`](https://learn.microsoft.com/dotnet/api/system.io.stream) |  |

---

### `SetEncapsulatedContent(bool)`

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

```csharp
public void SetEncapsulatedContent(bool includeEncapsulatedContent)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `includeEncapsulatedContent` | [`bool`](https://learn.microsoft.com/dotnet/api/system.boolean) |  |

---

### `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

```csharp
public void SetFinishSignature(bool finishSignature)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `finishSignature` | [`bool`](https://learn.microsoft.com/dotnet/api/system.boolean) |  |

---

### `SetPolicy(CadesPolicySpec)`

Sets the signature policy specification

```csharp
public void SetPolicy(CadesPolicySpec policy)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `policy` | [`CadesPolicySpec`](https://docs.lacunasoftware.com/api/Lacuna.Pki.Cades/CadesPolicySpec) | Policy specification |

---

### `SetPolicy(ICadesPolicyMapper)`

Sets a policy specification mapper

```csharp
public void SetPolicy(ICadesPolicyMapper policyMapper)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `policyMapper` | [`ICadesPolicyMapper`](https://docs.lacunasoftware.com/api/Lacuna.Pki.Cades/ICadesPolicyMapper) | Policy mapper |

---

### `SetPrecomputedSignature(byte[], byte[])`

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

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

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `signature` | [`byte[]`](https://learn.microsoft.com/dotnet/api/system.byte) | Signed bytes |
| `toSignBytes` | [`byte[]`](https://learn.microsoft.com/dotnet/api/system.byte) | To sign bytes used in the signing process |

---

### `SetPrecomputedSignature(byte[])`

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

```csharp
public void SetPrecomputedSignature(byte[] signature)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `signature` | [`byte[]`](https://learn.microsoft.com/dotnet/api/system.byte) | Signed bytes |

---

### `SetSignatureToCoSign(byte[])`

Sets the signature to create a co-signature

```csharp
public bool SetSignatureToCoSign(byte[] signature)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `signature` | [`byte[]`](https://learn.microsoft.com/dotnet/api/system.byte) | Signature content bytes |

**Retorno**

[`bool`](https://learn.microsoft.com/dotnet/api/system.boolean)

---

### `SetSignatureToCoSign(Stream)`

Sets the signature to create a co-signature

```csharp
public bool SetSignatureToCoSign(Stream stream)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `stream` | [`Stream`](https://learn.microsoft.com/dotnet/api/system.io.stream) | Signature stream |

**Retorno**

[`bool`](https://learn.microsoft.com/dotnet/api/system.boolean)

---

### `SetSigningCertificate(PKCertificate)`

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

```csharp
public void SetSigningCertificate(PKCertificate certificate)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `certificate` | [`PKCertificate`](https://docs.lacunasoftware.com/api/Lacuna.Pki/PKCertificate) | Certificate |

---

### `SetSigningCertificate(PKCertificateWithKey)`

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

```csharp
public void SetSigningCertificate(PKCertificateWithKey certWithKey)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `certWithKey` | [`PKCertificateWithKey`](https://docs.lacunasoftware.com/api/Lacuna.Pki/PKCertificateWithKey) | 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

```csharp
public void SetSigningDescription(string description)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `description` | [`string`](https://learn.microsoft.com/dotnet/api/system.string) |  |

---

### `SetTimestampRequester(ITimestampRequester)`

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

```csharp
public void SetTimestampRequester(ITimestampRequester tsRequester)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `tsRequester` | [`ITimestampRequester`](https://docs.lacunasoftware.com/api/Lacuna.Pki/ITimestampRequester) | Timestamp requester |

---

### `VerifyParameters(bool)`

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

```csharp
public void VerifyParameters(bool computingSignature = false)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `computingSignature` | [`bool`](https://learn.microsoft.com/dotnet/api/system.boolean) | 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

```csharp
public void WriteSignature(Stream stream)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `stream` | [`Stream`](https://learn.microsoft.com/dotnet/api/system.io.stream) | Stream |

---

## Membros herdados

[`ToString()`](https://learn.microsoft.com/dotnet/api/system.object.tostring), [`Equals(object)`](<https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)>), [`Equals(object, object)`](<https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)>), [`ReferenceEquals(object, object)`](https://learn.microsoft.com/dotnet/api/system.object.referenceequals), [`GetHashCode()`](https://learn.microsoft.com/dotnet/api/system.object.gethashcode), [`GetType()`](https://learn.microsoft.com/dotnet/api/system.object.gettype), [`MemberwiseClone()`](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone)
