---
title: "Assinar um arquivo com o Rest PKI Core"
product: "PKI Suite"
slug: "sign-a-file-rest-pki-core"
language: "pt"
canonical_url: "https://try.lacunasoftware.com/pt/pki-suite/sign-a-file-rest-pki-core"
docs_url: "https://docs.lacunasoftware.com/pt-br/articles/rest-pki/core"
samples:
  - title: "Sign a PDF with Rest PKI Core"
    language: "java"
    framework: "spring-boot"
    url: "https://github.com/LacunaSoftware/PkiSuiteSamples/blob/master/java/springmvc/src/main/java/com/lacunasoftware/pkisuite/controller/PadesSignatureCoreController.java"
  - title: "Sign a PDF with Rest PKI Core"
    language: "nodejs"
    framework: "express"
    url: "https://github.com/LacunaSoftware/PkiSuiteSamples/blob/master/nodejs/expressmvc/routes/pades-signature-core.js"
samples_repo: "https://github.com/LacunaSoftware/PkiSuiteSamples"
trace_recorded: "2026-10-12"
last_generated: "2026-10-12T15:24:28Z"
---

# Assinar um arquivo com o Rest PKI Core

Assine um arquivo com seu próprio certificado: o Rest PKI Core, o serviço em nuvem da Lacuna, faz a assinatura no servidor, e o Web PKI assina o hash dela no navegador, onde sua chave privada fica.

Live demo: [https://try.lacunasoftware.com/pt/pki-suite/sign-a-file-rest-pki-core](https://try.lacunasoftware.com/pt/pki-suite/sign-a-file-rest-pki-core). It runs against Lacuna's real products; this page describes it for AI coding agents.

## Call sequence

Recorded on 2026-10-12 against the real products with Lacuna's public test certificates and data. Keys, tokens, sessions, ids, file contents and personal data are masked.

### 1. List the visitor's certificates, with no filter.

In the browser: `pki.listCertificates()`

### 2. Read the chosen certificate's public part: no PIN is asked, and the key stays where it is.

In the browser: `pki.readCertificate({ thumbprint })`

### 3. Rest PKI Core validates the certificate, prepares the signature and returns the hash to sign and the state to keep.

On the server: `IRestPkiService.PrepareSignatureAsync`

`POST https://core.pki.rest/api/signature` → 200

Request:

```json
{
  "File": {
    "MimeType": "application/pdf",
    "Content": "<Content, 1609 bytes>",
    "Name": "document.pdf",
    "Length": 0,
    "ContentType": "application/pdf"
  },
  "Certificate": {
    "Content": "<Content, 1645 bytes>"
  },
  "SecurityContextId": "00000000-0000-0000-0000-000000000000",
  "SignatureType": 1,
  "PdfSignatureOptions": {
    "VisualRepresentation": {
      "Text": {
        "Text": "Digitally signed by Alan Mathison Turing\nCPF: ***.***.***-**\nDate: 2026-10-12 02:08 UTC",
        "IncludeSigningTime": false,
        "Container": {
          "Left": 0.2,
          "Top": 0.2,
          "Right": 0.2,
          "Bottom": 0.2
        }
      },
      "Position": {
        "PageNumber": -1,
        "MeasurementUnits": 1,
        "Auto": {
          "Container": {
            "Left": 1.5,
            "Right": 1.5,
            "Bottom": 1.5,
            "Height": 4.7
          },
          "SignatureRectangleSize": {
            "Height": 2.2,
            "Width": 5.8
          },
          "RowSpacing": 0.3
        }
      }
    },
    "BypassMarksIfSigned": false
  }
}
```

Response:

```json
{
  "success": true,
  "state": "***",
  "toSign": {
    "signatureAlgorithm": {
      "algorithm": "SHA256WithRSA",
      "oid": "1.2.840.113549.1.1.11",
      "digestAlgorithm": "SHA256",
      "digestAlgorithmOid": "2.16.840.1.101.3.4.2.1"
    },
    "data": "<data, 246 bytes>",
    "hash": "<hash, 32 bytes>",
    "digestInfo": "<base64, 51 bytes>"
  },
  "toSignHash": {
    "algorithm": "SHA256",
    "value": "<base64, 32 bytes>",
    "hexValue": "<hex, 32 bytes>"
  },
  "certificate": {
    "subjectName": {
      "country": "BR",
      "organization": "Lacuna Software",
      "commonName": "Alan Mathison Turing",
      "allValues": {
        "2.5.4.6": [
          "BR"
        ],
        "2.5.4.10": [
          "Lacuna Software"
        ],
        "2.5.4.3": [
          "Alan Mathison Turing"
        ]
      },
      "dnString": "CN=Alan Mathison Turing,O=Lacuna Software,C=BR"
    },
    "issuerName": {
      "country": "BR",
      "organization": "Lacuna Software",
      "organizationUnit": "IT",
      "commonName": "Lacuna CA Test v7",
      "allValues": {
        "2.5.4.6": [
          "BR"
        ],
        "2.5.4.10": [
          "Lacuna Software"
        ],
        "2.5.4.11": [
          "IT"
        ],
        "2.5.4.3": [
          "Lacuna CA Test v7"
        ]
      },
      "dnString": "CN=Lacuna CA Test v7,OU=IT,O=Lacuna Software,C=BR"
    },
    "issuerDisplayName": "Lacuna CA Test v7",
    "serialNumber": "<hex, 19 bytes>",
    "validityStart": "2025-01-03T14:16:57+00:00",
    "validityEnd": "2075-01-03T14:21:14+00:00",
    "issuer": {
      "subjectName": {
        "country": "BR",
        "organization": "Lacuna Software",
        "organizationUnit": "IT",
        "commonName": "Lacuna CA Test v7",
        "allValues": {
          "2.5.4.6": [
            "BR"
          ],
          "2.5.4.10": [
            "Lacuna Software"
          ],
          "2.5.4.11": [
            "IT"
          ],
          "2.5.4.3": [
            "Lacuna CA Test v7"
          ]
        },
        "dnString": "CN=Lacuna CA Test v7,OU=IT,O=Lacuna Software,C=BR"
      },
      "issuerName": {
        "country": "BR",
        "organization": "ICP-Brasil",
        "organizationUnit": "Lacuna Software - LS",
        "commonName": "Lacuna Root Test v3",
        "allValues": {
          "2.5.4.6": [
            "BR"
          ],
          "2.5.4.10": [
            "ICP-Brasil"
          ],
          "2.5.4.11": [
            "Lacuna Software - LS"
          ],
          "2.5.4.3": [
            "Lacuna Root Test v3"
          ]
        },
        "dnString": "CN=Lacuna Root Test v3,OU=Lacuna Software - LS,O=ICP-Brasil,C=BR"
      },
      "issuerDisplayName": "Lacuna Root Test v3",
      "serialNumber": "3",
      "validityStart": "2024-12-16T21:30:30+00:00",
      "validityEnd": "2074-12-16T03:00:00+00:00",
      "issuer": {
        "subjectName": {
          "country": "BR",
          "organization": "ICP-Brasil",
          "organizationUnit": "Lacuna Software - LS",
          "commonName": "Lacuna Root Test v3",
          "allValues": {
            "2.5.4.6": [
              "BR"
            ],
            "2.5.4.10": [
              "ICP-Brasil"
            ],
            "2.5.4.11": [
              "Lacuna Software - LS"
            ],
            "2.5.4.3": [
              "Lacuna Root Test v3"
            ]
          },
          "dnString": "CN=Lacuna Root Test v3,OU=Lacuna Software - LS,O=ICP-Brasil,C=BR"
        },
        "issuerName": {
          "country": "BR",
          "organization": "ICP-Brasil",
          "organizationUnit": "Lacuna Software - LS",
          "commonName": "Lacuna Root Test v3",
          "allValues": {
            "2.5.4.6": [
              "BR"
            ],
            "2.5.4.10": [
              "ICP-Brasil"
            ],
            "2.5.4.11": [
              "Lacuna Software - LS"
            ],
            "2.5.4.3": [
              "Lacuna Root Test v3"
            ]
          },
          "dnString": "CN=Lacuna Root Test v3,OU=Lacuna Software - LS,O=ICP-Brasil,C=BR"
        },
        "issuerDisplayName": "Lacuna Root Test v3",
        "serialNumber": "1",
        "validityStart": "2024-12-16T20:42:10+00:00",
        "validityEnd": "2074-12-16T03:00:00+00:00",
        "pkiBrazil": {
          "certificateType": "Unknown"
        },
        "pkiItaly": {
          "certificateType": "Undefined"
        },
        "binaryThumbprintSHA256": "<base64, 32 bytes>",
        "thumbprint": "<hex, 20 bytes>",
        "thumbprintSHA256": "<hex, 32 bytes>",
        "subjectCommonName": "Lacuna Root Test v3",
        "subjectDisplayName": "Lacuna Root Test v3",
        "organization": "ICP-Brasil"
      },
      "pkiBrazil": {
        "certificateType": "Unknown"
      },
      "pkiItaly": {
        "certificateType": "Undefined"
      },
      "binaryThumbprintSHA256": "<base64, 32 bytes>",
      "thumbprint": "<hex, 20 bytes>",
      "thumbprintSHA256": "<thumbprintSHA256, 44 chars>",
      "subjectCommonName": "Lacuna CA Test v7",
      "subjectDisplayName": "Lacuna CA Test v7",
      "organization": "Lacuna Software"
    },
    "pkiBrazil": {
      "certificateType": "A1",
      "cpf": "***.***.***-**",
      "responsavel": "Alan Mathison Turing",
      "dateOfBirth": "2000-01-01"
    },
    "pkiItaly": {
      "certificateType": "Undefined"
    },
    "binaryThumbprintSHA256": "<base64, 32 bytes>",
    "thumbprint": "<hex, 20 bytes>",
    "thumbprintSHA256": "<hex, 32 bytes>",
    "subjectCommonName": "Alan Mathison Turing",
    "subjectDisplayName": "Alan Mathison Turing",
    "subjectIdentifier": "***",
    "emailAddress": "someone@example.com"
  }
}
```

### 4. Sign the hash with the certificate's private key, behind the system's PIN prompt: the key never leaves the browser's store or token.

In the browser: `pki.signHash({ thumbprint, hash, digestAlgorithm })`

### 5. Rest PKI Core completes the signature with the state and the signed hash; the signed file and its signer are read back.

On the server: `IRestPkiService.CompleteSignatureAsync`

`POST https://core.pki.rest/api/signature/completion` → 200

Request:

```json
{
  "State": "***",
  "Signature": "<Signature, 256 bytes>"
}
```

Response:

```json
{
  "signers": [
    {
      "certificate": {
        "thumbprint": "<hex, 20 bytes>",
        "thumbprintSHA256": "<hex, 32 bytes>",
        "subjectCommonName": "Alan Mathison Turing",
        "subjectDisplayName": "Alan Mathison Turing",
        "subjectIdentifier": "***",
        "emailAddress": "someone@example.com"
      },
      "date": "2026-10-12T02:08:02+00:00"
    }
  ],
  "metadata": {},
  "signatureSessionIds": [],
  "id": "00000000-0000-0000-0000-000000000000",
  "key": "***",
  "dateCreated": "2026-10-12T02:08:02.5292938+00:00",
  "subscriptionId": "00000000-0000-0000-0000-000000000000",
  "formattedKey": "***",
  "originalFile": {
    "mimeType": "application/pdf",
    "url": "https://restpkicore.lacunasoftware.com/api/documents/00000000-0000-0000-0000-000000000000/original-file?access_ticket={value}&culture=en",
    "name": "document.pdf",
    "length": 1609,
    "contentType": "application/pdf",
    "location": "https://restpkicore.lacunasoftware.com/api/documents/00000000-0000-0000-0000-000000000000/original-file?access_ticket={value}&culture=en"
  },
  "markedFile": {
    "mimeType": "application/pdf",
    "url": "https://restpkicore.lacunasoftware.com/api/documents/00000000-0000-0000-0000-000000000000/marked-file?access_ticket={value}&culture=en",
    "name": "document.pdf",
    "length": 21890,
    "contentType": "application/pdf",
    "location": "https://restpkicore.lacunasoftware.com/api/documents/00000000-0000-0000-0000-000000000000/marked-file?access_ticket={value}&culture=en"
  },
  "signedFile": {
    "mimeType": "application/pdf",
    "url": "https://restpkicore.lacunasoftware.com/api/documents/00000000-0000-0000-0000-000000000000/signed-file?access_ticket={value}&culture=en",
    "name": "document.pdf",
    "length": 47280,
    "contentType": "application/pdf",
    "location": "https://restpkicore.lacunasoftware.com/api/documents/00000000-0000-0000-0000-000000000000/signed-file?access_ticket={value}&culture=en"
  },
  "signatureType": "Pdf"
}
```

`GET https://restpkicore.lacunasoftware.com/api/documents/00000000-0000-0000-0000-000000000000/signed-file?access_ticket={value}&culture=en` → 200

Response:

```json
"<application/pdf, 47280 bytes>"
```

`GET https://core.pki.rest/api/documents/00000000-0000-0000-0000-000000000000/signers` → 200

Response:

```json
[
  {
    "messageDigest": {
      "algorithm": "SHA256",
      "value": "<base64, 32 bytes>",
      "hexValue": "<hex, 32 bytes>"
    },
    "signature": {
      "algorithmIdentifier": {
        "algorithm": "SHA256WithRSA",
        "oid": "1.2.840.113549.1.1.11",
        "digestAlgorithm": "SHA256",
        "digestAlgorithmOid": "2.16.840.1.101.3.4.2.1"
      },
      "value": "<base64, 256 bytes>",
      "hexValue": "<hexValue, 46 chars>"
    },
    "signingTime": "2026-10-12T02:08:02+00:00",
    "timestamps": [],
    "archiveTimestamps": [],
    "isDocumentTimestamp": false,
    "signatureFieldName": "Signature1",
    "validationResults": {
      "passedChecks": [
        {
          "type": "Success",
          "message": "Success",
          "detail": "The content-type and message digest present in the signed attributes match the ones in the CMS"
        },
        {
          "type": "Success",
          "message": "Success",
          "detail": "The signing certificate digest present in the signed attributes matches the signer's certificate"
        },
        {
          "type": "Success",
          "message": "Success",
          "detail": "The signature value is correct"
        },
        "… and 14 more"
      ],
      "errors": [],
      "warnings": []
    },
    "hasLtv": true,
    "attributeCertificates": [],
    "certificate": {
      "subjectName": {
        "country": "BR",
        "organization": "Lacuna Software",
        "commonName": "Alan Mathison Turing",
        "allValues": {
          "2.5.4.6": [
            "BR"
          ],
          "2.5.4.10": [
            "Lacuna Software"
          ],
          "2.5.4.3": [
            "Alan Mathison Turing"
          ]
        },
        "dnString": "CN=Alan Mathison Turing,O=Lacuna Software,C=BR"
      },
      "issuerName": {
        "country": "BR",
        "organization": "Lacuna Software",
        "organizationUnit": "IT",
        "commonName": "Lacuna CA Test v7",
        "allValues": {
          "2.5.4.6": [
            "BR"
          ],
          "2.5.4.10": [
            "Lacuna Software"
          ],
          "2.5.4.11": [
            "IT"
          ],
          "2.5.4.3": [
            "Lacuna CA Test v7"
          ]
        },
        "dnString": "CN=Lacuna CA Test v7,OU=IT,O=Lacuna Software,C=BR"
      },
      "issuerDisplayName": "Lacuna CA Test v7",
      "serialNumber": "<hex, 19 bytes>",
      "validityStart": "2025-01-03T14:16:57+00:00",
      "validityEnd": "2075-01-03T14:21:14+00:00",
      "issuer": {
        "subjectName": {
          "country": "BR",
          "organization": "Lacuna Software",
          "organizationUnit": "IT",
          "commonName": "Lacuna CA Test v7",
          "allValues": {
            "2.5.4.6": [
              "BR"
            ],
            "2.5.4.10": [
              "Lacuna Software"
            ],
            "2.5.4.11": [
              "IT"
            ],
            "2.5.4.3": [
              "Lacuna CA Test v7"
            ]
          },
          "dnString": "CN=Lacuna CA Test v7,OU=IT,O=Lacuna Software,C=BR"
        },
        "issuerName": {
          "country": "BR",
          "organization": "ICP-Brasil",
          "organizationUnit": "Lacuna Software - LS",
          "commonName": "Lacuna Root Test v3",
          "allValues": {
            "2.5.4.6": [
              "BR"
            ],
            "2.5.4.10": [
              "ICP-Brasil"
            ],
            "2.5.4.11": [
              "Lacuna Software - LS"
            ],
            "2.5.4.3": [
              "Lacuna Root Test v3"
            ]
          },
          "dnString": "CN=Lacuna Root Test v3,OU=Lacuna Software - LS,O=ICP-Brasil,C=BR"
        },
        "issuerDisplayName": "Lacuna Root Test v3",
        "serialNumber": "3",
        "validityStart": "2024-12-16T21:30:30+00:00",
        "validityEnd": "2074-12-16T03:00:00+00:00",
        "issuer": {
          "subjectName": {
            "country": "BR",
            "organization": "ICP-Brasil",
            "organizationUnit": "Lacuna Software - LS",
            "commonName": "Lacuna Root Test v3",
            "allValues": {
              "2.5.4.6": [
                "BR"
              ],
              "2.5.4.10": [
                "ICP-Brasil"
              ],
              "2.5.4.11": [
                "Lacuna Software - LS"
              ],
              "2.5.4.3": [
                "Lacuna Root Test v3"
              ]
            },
            "dnString": "CN=Lacuna Root Test v3,OU=Lacuna Software - LS,O=ICP-Brasil,C=BR"
          },
          "issuerName": {
            "country": "BR",
            "organization": "ICP-Brasil",
            "organizationUnit": "Lacuna Software - LS",
            "commonName": "Lacuna Root Test v3",
            "allValues": {
              "2.5.4.6": [
                "BR"
              ],
              "2.5.4.10": [
                "ICP-Brasil"
              ],
              "2.5.4.11": [
                "Lacuna Software - LS"
              ],
              "2.5.4.3": [
                "Lacuna Root Test v3"
              ]
            },
            "dnString": "CN=Lacuna Root Test v3,OU=Lacuna Software - LS,O=ICP-Brasil,C=BR"
          },
          "issuerDisplayName": "Lacuna Root Test v3",
          "serialNumber": "1",
          "validityStart": "2024-12-16T20:42:10+00:00",
          "validityEnd": "2074-12-16T03:00:00+00:00",
          "pkiBrazil": {
            "certificateType": "Unknown"
          },
          "pkiItaly": {
            "certificateType": "Undefined"
          },
          "binaryThumbprintSHA256": "<base64, 32 bytes>",
          "thumbprint": "<hex, 20 bytes>",
          "thumbprintSHA256": "<hex, 32 bytes>",
          "subjectCommonName": "Lacuna Root Test v3",
          "subjectDisplayName": "Lacuna Root Test v3",
          "organization": "ICP-Brasil"
        },
        "pkiBrazil": {
          "certificateType": "Unknown"
        },
        "pkiItaly": {
          "certificateType": "Undefined"
        },
        "binaryThumbprintSHA256": "<base64, 32 bytes>",
        "thumbprint": "<hex, 20 bytes>",
        "thumbprintSHA256": "<thumbprintSHA256, 44 chars>",
        "subjectCommonName": "Lacuna CA Test v7",
        "subjectDisplayName": "Lacuna CA Test v7",
        "organization": "Lacuna Software"
      },
      "pkiBrazil": {
        "certificateType": "A1",
        "cpf": "***.***.***-**",
        "responsavel": "Alan Mathison Turing",
        "dateOfBirth": "2000-01-01"
      },
      "pkiItaly": {
        "certificateType": "Undefined"
      },
      "binaryThumbprintSHA256": "<base64, 32 bytes>",
      "thumbprint": "<hex, 20 bytes>",
      "thumbprintSHA256": "<hex, 32 bytes>",
      "subjectCommonName": "Alan Mathison Turing",
      "subjectDisplayName": "Alan Mathison Turing",
      "subjectIdentifier": "***",
      "emailAddress": "someone@example.com"
    },
    "date": "0001-01-01T00:00:00+00:00"
  }
]
```

### 6. Rest PKI Core inspects the signed file for the validation report shown beside the result.

On the server: `PUT api/signature-inspection`

`PUT https://core.pki.rest/api/signature-inspection` → 200

Request:

```json
{
  "file": {
    "mimeType": "application/pdf",
    "content": "<content, 47280 bytes>",
    "name": "document.pdf",
    "length": 0,
    "contentType": "application/pdf"
  },
  "validate": true,
  "securityContextId": "00000000-0000-0000-0000-000000000000",
  "ignoreRevocationStatusUnknown": false,
  "trustUncertifiedSigningTime": false,
  "extractEncapsulatedContent": false
}
```

Response:

```json
{
  "success": true,
  "signers": [
    {
      "messageDigest": {
        "algorithm": "SHA256",
        "value": "<base64, 32 bytes>",
        "hexValue": "<hex, 32 bytes>"
      },
      "signature": {
        "algorithmIdentifier": {
          "algorithm": "SHA256WithRSA",
          "oid": "1.2.840.113549.1.1.11",
          "digestAlgorithm": "SHA256",
          "digestAlgorithmOid": "2.16.840.1.101.3.4.2.1"
        },
        "value": "<base64, 256 bytes>",
        "hexValue": "<hexValue, 46 chars>"
      },
      "signingTime": "2026-10-12T02:08:02+00:00",
      "timestamps": [],
      "archiveTimestamps": [],
      "isDocumentTimestamp": false,
      "signatureFieldName": "Signature1",
      "validationResults": {
        "passedChecks": [
          {
            "type": "Success",
            "message": "Success",
            "detail": "The content-type and message digest present in the signed attributes match the ones in the CMS"
          },
          {
            "type": "Success",
            "message": "Success",
            "detail": "The signing certificate digest present in the signed attributes matches the signer's certificate"
          },
          {
            "type": "Success",
            "message": "Success",
            "detail": "The signature value is correct"
          },
          "… and 14 more"
        ],
        "errors": [],
        "warnings": []
      },
      "hasLtv": true,
      "attributeCertificates": [],
      "certificate": {
        "subjectName": {
          "country": "BR",
          "organization": "Lacuna Software",
          "commonName": "Alan Mathison Turing",
          "allValues": {
            "2.5.4.6": [
              "BR"
            ],
            "2.5.4.10": [
              "Lacuna Software"
            ],
            "2.5.4.3": [
              "Alan Mathison Turing"
            ]
          },
          "dnString": "CN=Alan Mathison Turing,O=Lacuna Software,C=BR"
        },
        "issuerName": {
          "country": "BR",
          "organization": "Lacuna Software",
          "organizationUnit": "IT",
          "commonName": "Lacuna CA Test v7",
          "allValues": {
            "2.5.4.6": [
              "BR"
            ],
            "2.5.4.10": [
              "Lacuna Software"
            ],
            "2.5.4.11": [
              "IT"
            ],
            "2.5.4.3": [
              "Lacuna CA Test v7"
            ]
          },
          "dnString": "CN=Lacuna CA Test v7,OU=IT,O=Lacuna Software,C=BR"
        },
        "issuerDisplayName": "Lacuna CA Test v7",
        "serialNumber": "<hex, 19 bytes>",
        "validityStart": "2025-01-03T14:16:57+00:00",
        "validityEnd": "2075-01-03T14:21:14+00:00",
        "issuer": {
          "subjectName": {
            "country": "BR",
            "organization": "Lacuna Software",
            "organizationUnit": "IT",
            "commonName": "Lacuna CA Test v7",
            "allValues": {
              "2.5.4.6": [
                "BR"
              ],
              "2.5.4.10": [
                "Lacuna Software"
              ],
              "2.5.4.11": [
                "IT"
              ],
              "2.5.4.3": [
                "Lacuna CA Test v7"
              ]
            },
            "dnString": "CN=Lacuna CA Test v7,OU=IT,O=Lacuna Software,C=BR"
          },
          "issuerName": {
            "country": "BR",
            "organization": "ICP-Brasil",
            "organizationUnit": "Lacuna Software - LS",
            "commonName": "Lacuna Root Test v3",
            "allValues": {
              "2.5.4.6": [
                "BR"
              ],
              "2.5.4.10": [
                "ICP-Brasil"
              ],
              "2.5.4.11": [
                "Lacuna Software - LS"
              ],
              "2.5.4.3": [
                "Lacuna Root Test v3"
              ]
            },
            "dnString": "CN=Lacuna Root Test v3,OU=Lacuna Software - LS,O=ICP-Brasil,C=BR"
          },
          "issuerDisplayName": "Lacuna Root Test v3",
          "serialNumber": "3",
          "validityStart": "2024-12-16T21:30:30+00:00",
          "validityEnd": "2074-12-16T03:00:00+00:00",
          "issuer": {
            "subjectName": {
              "country": "BR",
              "organization": "ICP-Brasil",
              "organizationUnit": "Lacuna Software - LS",
              "commonName": "Lacuna Root Test v3",
              "allValues": {
                "2.5.4.6": [
                  "BR"
                ],
                "2.5.4.10": [
                  "ICP-Brasil"
                ],
                "2.5.4.11": [
                  "Lacuna Software - LS"
                ],
                "2.5.4.3": [
                  "Lacuna Root Test v3"
                ]
              },
              "dnString": "CN=Lacuna Root Test v3,OU=Lacuna Software - LS,O=ICP-Brasil,C=BR"
            },
            "issuerName": {
              "country": "BR",
              "organization": "ICP-Brasil",
              "organizationUnit": "Lacuna Software - LS",
              "commonName": "Lacuna Root Test v3",
              "allValues": {
                "2.5.4.6": [
                  "BR"
                ],
                "2.5.4.10": [
                  "ICP-Brasil"
                ],
                "2.5.4.11": [
                  "Lacuna Software - LS"
                ],
                "2.5.4.3": [
                  "Lacuna Root Test v3"
                ]
              },
              "dnString": "CN=Lacuna Root Test v3,OU=Lacuna Software - LS,O=ICP-Brasil,C=BR"
            },
            "issuerDisplayName": "Lacuna Root Test v3",
            "serialNumber": "1",
            "validityStart": "2024-12-16T20:42:10+00:00",
            "validityEnd": "2074-12-16T03:00:00+00:00",
            "pkiBrazil": {
              "certificateType": "Unknown"
            },
            "pkiItaly": {
              "certificateType": "Undefined"
            },
            "binaryThumbprintSHA256": "<base64, 32 bytes>",
            "thumbprint": "<hex, 20 bytes>",
            "thumbprintSHA256": "<hex, 32 bytes>",
            "subjectCommonName": "Lacuna Root Test v3",
            "subjectDisplayName": "Lacuna Root Test v3",
            "organization": "ICP-Brasil"
          },
          "pkiBrazil": {
            "certificateType": "Unknown"
          },
          "pkiItaly": {
            "certificateType": "Undefined"
          },
          "binaryThumbprintSHA256": "<base64, 32 bytes>",
          "thumbprint": "<hex, 20 bytes>",
          "thumbprintSHA256": "<thumbprintSHA256, 44 chars>",
          "subjectCommonName": "Lacuna CA Test v7",
          "subjectDisplayName": "Lacuna CA Test v7",
          "organization": "Lacuna Software"
        },
        "pkiBrazil": {
          "certificateType": "A1",
          "cpf": "***.***.***-**",
          "responsavel": "Alan Mathison Turing",
          "dateOfBirth": "2000-01-01"
        },
        "pkiItaly": {
          "certificateType": "Undefined"
        },
        "binaryThumbprintSHA256": "<base64, 32 bytes>",
        "thumbprint": "<hex, 20 bytes>",
        "thumbprintSHA256": "<hex, 32 bytes>",
        "subjectCommonName": "Alan Mathison Turing",
        "subjectDisplayName": "Alan Mathison Turing",
        "subjectIdentifier": "***",
        "emailAddress": "someone@example.com"
      },
      "date": "0001-01-01T00:00:00+00:00"
    }
  ],
  "document": {
    "id": "00000000-0000-0000-0000-000000000000",
    "key": "***",
    "dateCreated": "2026-10-12T02:08:02.5292938+00:00",
    "subscriptionId": "00000000-0000-0000-0000-000000000000",
    "formattedKey": "***",
    "originalFile": {
      "mimeType": "application/pdf",
      "url": "https://restpkicore.lacunasoftware.com/api/documents/00000000-0000-0000-0000-000000000000/original-file?access_ticket={value}&culture=en",
      "name": "document.pdf",
      "length": 1609,
      "contentType": "application/pdf",
      "location": "https://restpkicore.lacunasoftware.com/api/documents/00000000-0000-0000-0000-000000000000/original-file?access_ticket={value}&culture=en"
    },
    "markedFile": {
      "mimeType": "application/pdf",
      "url": "https://restpkicore.lacunasoftware.com/api/documents/00000000-0000-0000-0000-000000000000/marked-file?access_ticket={value}&culture=en",
      "name": "document.pdf",
      "length": 21890,
      "contentType": "application/pdf",
      "location": "https://restpkicore.lacunasoftware.com/api/documents/00000000-0000-0000-0000-000000000000/marked-file?access_ticket={value}&culture=en"
    },
    "signedFile": {
      "mimeType": "application/pdf",
      "url": "https://restpkicore.lacunasoftware.com/api/documents/00000000-0000-0000-0000-000000000000/signed-file?access_ticket={value}&culture=en",
      "name": "document.pdf",
      "length": 47280,
      "contentType": "application/pdf",
      "location": "https://restpkicore.lacunasoftware.com/api/documents/00000000-0000-0000-0000-000000000000/signed-file?access_ticket={value}&culture=en"
    },
    "signatureType": "Pdf"
  }
}
```

## Patterns to copy

- The private key stays in the browser: Rest PKI Core prepares the signature and returns the hash to sign, Web PKI's `signHash` signs it, and your server completes the signature. Keep the prepare call's `State` until the completion.
- Send the security context id on every prepare and inspection, and fail before any request when it is missing, rather than fall back to the subscription's default context. Rest PKI Core validates the certificate at prepare and decides the policy and any timestamp itself.
- Register the client with `services.AddRestPki()` and bind `RestPkiOptions`, so its `HttpClient` comes from `IHttpClientFactory`; don't use `RestPkiServiceFactory.GetService(...)`, which builds its own.
- Fetch the signed file through the client (`SignedFile.GetContentAsync`): its temporary link carries an access ticket, so never log it.
- `Lacuna.RestPkiCore.Client` 5.0.0 has no signature-inspection method and its signers call drops the policy and timestamps: the Demo sends `PUT api/signature-inspection` and `GET api/documents/{id}/signers` itself, with the package's models. Only the first 10 signers are validated.

## Links

- Live demo: https://try.lacunasoftware.com/en/pki-suite/sign-a-file-rest-pki-core (Portuguese: https://try.lacunasoftware.com/pt/pki-suite/sign-a-file-rest-pki-core)
- Docs: https://docs.lacunasoftware.com/pt-br/articles/rest-pki/core
- Sample, Java (spring-boot): [Sign a PDF with Rest PKI Core](https://github.com/LacunaSoftware/PkiSuiteSamples/blob/master/java/springmvc/src/main/java/com/lacunasoftware/pkisuite/controller/PadesSignatureCoreController.java)
- Sample, Node.js (express): [Sign a PDF with Rest PKI Core](https://github.com/LacunaSoftware/PkiSuiteSamples/blob/master/nodejs/expressmvc/routes/pades-signature-core.js)
- Related demo: [Assinar um arquivo com seu certificado](https://try.lacunasoftware.com/pt/pki-suite/sign-a-file.md): Prefere assinar no seu próprio servidor? Experimente com o PKI SDK
- Every demo: https://try.lacunasoftware.com/llms.txt and https://try.lacunasoftware.com/demos.json
