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

# XmlSigner

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

```csharp
public abstract class XmlSigner
```

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

## Construtores

### `XmlSigner()`

```csharp
public XmlSigner()
```

---

## Campos

### `namespaceMan`

```csharp
protected NamespaceManager namespaceMan
```

**Retorno**

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

---

### `xmlDocument`

```csharp
protected XmlDocument xmlDocument
```

**Retorno**

[`XmlDocument`](https://learn.microsoft.com/dotnet/api/system.xml.xmldocument)

---

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

### `AddReferences(SignedXml, DigestAlgorithm, XmlPolicySpec)`

```csharp
protected abstract void AddReferences(SignedXml signedXml, DigestAlgorithm digestAlgorithm, XmlPolicySpec policy)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `signedXml` | [`SignedXml`](https://learn.microsoft.com/dotnet/api/system.security.cryptography.xml.signedxml) |  |
| `digestAlgorithm` | [`DigestAlgorithm`](https://docs.lacunasoftware.com/api/Lacuna.Pki/DigestAlgorithm) |  |
| `policy` | [`XmlPolicySpec`](https://docs.lacunasoftware.com/api/Lacuna.Pki.Xml/XmlPolicySpec) |  |

---

### `ComputeSignature()`

Computes the XML signature

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

---

### `FulfillTransformations(Reference)`

```csharp
protected void FulfillTransformations(Reference reference)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `reference` | [`Reference`](https://learn.microsoft.com/dotnet/api/system.security.cryptography.xml.reference) |  |

---

### `GenerateToSignHash(out SignatureAlgorithm, out byte[])`

Generates the hash to be signed by the user in an asynchronous signature. In the next step, in possesion of the signed hash and the persisted transferData, you must call the SetPrecomputedSignature method

```csharp
public byte[] GenerateToSignHash(out SignatureAlgorithm signatureAlgorithm, out byte[] transferData)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `signatureAlgorithm` | [`SignatureAlgorithm`](https://docs.lacunasoftware.com/api/Lacuna.Pki/SignatureAlgorithm) | The signature algorithm to be used in the user signature |
| `transferData` | [`byte[]`](https://learn.microsoft.com/dotnet/api/system.byte) | The data to be persisted until the next step |

**Retorno**

[`byte[]`](https://learn.microsoft.com/dotnet/api/system.byte) — The hash to be signed by the user

---

### `GetSignatureElement()`

Returns the computed XML signature element only

```csharp
public XmlElement GetSignatureElement()
```

**Retorno**

[`XmlElement`](https://learn.microsoft.com/dotnet/api/system.xml.xmlelement)

---

### `GetSignedXml()`

Returns the XML document containing the computed signature element

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

**Retorno**

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

---

### `GetToSignEntityTransferData()`

```csharp
protected abstract byte[] GetToSignEntityTransferData()
```

**Retorno**

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

---

### `InsertSignatureElement()`

Inserts the computed signature element in the XML document

```csharp
public virtual void InsertSignatureElement()
```

---

### `InsertSignatureElement(XmlElement, string, XmlInsertionOptions)`

```csharp
protected virtual void InsertSignatureElement(XmlElement signatureElement, string xpath, XmlInsertionOptions insertionOption)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `signatureElement` | [`XmlElement`](https://learn.microsoft.com/dotnet/api/system.xml.xmlelement) |  |
| `xpath` | [`string`](https://learn.microsoft.com/dotnet/api/system.string) |  |
| `insertionOption` | [`XmlInsertionOptions`](https://docs.lacunasoftware.com/api/Lacuna.Pki.Xml/XmlInsertionOptions) |  |

---

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

---

### `SetClassicEnvelopedTransformation(bool)`

Sets whether or not to use classic enveloped transformation on enveloped signatures.
By default XML Signers adds an XPath transformation along with enveloped transformation, which allows
multiple new signatures to the XML. Case true, the default XPath transformation is not included,
therefore, adding new signatures to the XML is not allowed and will break previous signatures validation.

```csharp
public void SetClassicEnvelopedTransformation(bool useClassicEnveloped)
```

**Parâmetros**

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

---

### `SetCommitmentType(CommitmentType)`

Sets the signer commitment type signed attribute for all signed data. If executing a remote signature, the commitment type
must be passed again in the compute signature step

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

**Parâmetros**

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

---

### `SetDataObjectFormat(string)`

Sets a custom text describing the signing operation. If set, it will be inlcuded as
a DataObjectFormat signed data property

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

**Parâmetros**

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

---

### `SetPolicy(IXmlPolicyMapper)`

Sets the XML signature policy mapper

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

**Parâmetros**

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

---

### `SetPolicy(XmlPolicySpec)`

Sets the XML signature policy

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

**Parâmetros**

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

---

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

Sets the precomputed signture and persisted data in an asynchronous signature

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

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `signature` | [`byte[]`](https://learn.microsoft.com/dotnet/api/system.byte) | The user signature of the hash given by the method GenerateToSignHash |
| `transferData` | [`byte[]`](https://learn.microsoft.com/dotnet/api/system.byte) | The data given by the method GenerateToSignHash |

---

### `SetSignatureElementId(string)`

Sets the computed signature element ID

```csharp
public void SetSignatureElementId(string id)
```

**Parâmetros**

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

---

### `SetSignatureElementLocation(string, NamespaceManager, XmlInsertionOptions)`

Sets the location of the computed signature element to be inserted in the XML document

```csharp
public void SetSignatureElementLocation(string xpath, NamespaceManager namespaceMan, XmlInsertionOptions insertionOption)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `xpath` | [`string`](https://learn.microsoft.com/dotnet/api/system.string) | The xpath to select the target element which the insertion will be related to. If null, XML root element will be selected. |
| `namespaceMan` | [`NamespaceManager`](https://docs.lacunasoftware.com/api/Lacuna.Pki.Xml/NamespaceManager) | The namespaces and prefixes of the XML used in the xpath |
| `insertionOption` | [`XmlInsertionOptions`](https://docs.lacunasoftware.com/api/Lacuna.Pki.Xml/XmlInsertionOptions) | The insertion option that will be applied over the target element define by xpath |

---

### `SetSigningCertificate(PKCertificate)`

Sets the signing certificate. Used in an asynchronous signature

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

**Parâmetros**

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

---

### `SetSigningCertificate(PKCertificateWithKey)`

Sets the signing certificate with private key. Used in a synchronous signature

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

**Parâmetros**

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

---

### `SetTimestampRequester(ITimestampRequester)`

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

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

**Parâmetros**

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

---

### `SetToSignEntityTransferData(byte[])`

```csharp
protected abstract void SetToSignEntityTransferData(byte[] transferData)
```

**Parâmetros**

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

---

### `SetXml(byte[])`

Sets the XML document bytes

```csharp
public void SetXml(byte[] xmlDocumentBytes)
```

**Parâmetros**

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

---

### `SetXml(XmlDocument)`

Sets the XML document

```csharp
public void SetXml(XmlDocument xmlDoc)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `xmlDoc` | [`XmlDocument`](https://learn.microsoft.com/dotnet/api/system.xml.xmldocument) | XML document |

---

### `VerifyParameters(bool)`

```csharp
protected virtual void VerifyParameters(bool computeSignature)
```

**Parâmetros**

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

---

### `VerifySignerParameters(bool)`

Verifies if the Xml signer necessary parameters are set. If not, throws Exception.

```csharp
public void VerifySignerParameters(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. |

---

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