# XML Signature Verifier (XMLDSig / XAdES) API

> Verify every XML signature in a document: reference digests, RSA / ECDSA value, signer certificate, chain to Vietnamese CAs, signing time, XAdES.

- Endpoint: `POST https://apibox.io.vn/v1/xml-dsig`
- Category: Security & Crypto
- HTML docs: https://apibox.io.vn/docs/xml-dsig/ (Vietnamese: https://apibox.io.vn/vi/docs/xml-dsig/)
- Online tool: https://apibox.io.vn/tools/xml-dsig/
- Authentication: `Authorization: Bearer <API key>` or `X-API-Key: <API key>` (free key: https://apibox.io.vn/dashboard/#signup)

Send an XML document (Vietnamese e-invoice, tax return, social insurance file, UBL / Peppol invoice, SAML message or any XML) and every `ds:Signature` in it is checked. For each `Reference` the target element is canonicalised (C14N 1.0 / 1.1, exclusive C14N, with or without comments; enveloped-signature and the `not(ancestor-or-self::ds:Signature)` XPath transform) and its digest compared: `modified_elements` names the element that was changed after signing, e.g. `/HDon/DLHDon` when an amount on an invoice was edited. The `SignatureValue` is then verified (RSA SHA-1 / 256 / 384 / 512, ECDSA P-256 / 384 / 521) over the canonical `SignedInfo`.

The signer certificate (embedded `X509Certificate`, or your own `cert`) is decoded with the Vietnamese identifiers commonly put in the subject (MST, CCCD, budget code), and its chain is built against the Vietnamese public CA list published by NEAC (rootca.gov.vn) and Ban Cơ yếu Chính phủ: `status` is `valid` (trusted chain or your certificate), `valid_untrusted` (mathematically valid, unknown issuer) or `invalid`. The signing time comes from XAdES `SigningTime` or the `SignatureProperties` used by Vietnamese e-invoices, with whether it is covered by the signature; XAdES `SigningCertificate` digests are compared too. On e-invoices the role (seller, buyer, tax authority) is read from `DSCKS`.

Same-document references only; DTDs and custom entities are refused (XXE protection); max 1 MB. Revocation (OCSP / CRL) is not checked. The service never takes private keys and never signs. Technical check only, not a legal validation.

## Parameters

| Name | In | Type | Required | Default | Description |
|---|---|---|---|---|---|
| `xml` | body | string | no |  | The signed XML (or send it as a raw `application/xml` body, a multipart `file`, `xml_base64` or `xml_url`). Max 1 MB. |
| `file` | body | file | no |  | XML file (multipart). |
| `cert` | body | string | no |  | Expected signer certificate(s), PEM or base64 DER: a signature verified with it gets status `valid`. |

## Example request

```bash
curl -X POST "https://apibox.io.vn/v1/xml-dsig" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/xml" \
  --data-binary '<ToKhai Id="tk1"><MST>0101234567</MST><KyKKhai>10/2026</KyKKhai><Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo>…</SignedInfo><SignatureValue>…</SignatureValue><KeyInfo><X509Data><X509Certificate>MIIDoTCC…</X509Certificate></X509Data></KeyInfo></Signature></ToKhai>'
```

## Example response

```json
{
  "signature_count": 1,
  "all_valid": true,
  "summary": "All 1 signature(s) are cryptographically valid",
  "summary_vi": "Tất cả 1 chữ ký hợp lệ về mặt mật mã",
  "signatures": [
    {
      "path": "/ToKhai/Signature",
      "id": null,
      "canonicalization": "c14n",
      "signature_algorithm": "rsa-sha1",
      "references": [
        {
          "uri": "#tk1",
          "type": null,
          "target": "/ToKhai",
          "digest_algorithm": "sha1",
          "transforms": [
            "enveloped-signature",
            "c14n"
          ],
          "digest_valid": true
        }
      ],
      "modified_elements": [],
      "signature_valid": true,
      "digests_valid": true,
      "valid": true,
      "key_source": "embedded X509Certificate",
      "signing_time": null,
      "signing_time_source": null,
      "certificate": {
        "subject": {
          "C": "VN",
          "O": "CONG TY TEST",
          "CN": "CONG TY TNHH TEST",
          "UID": "MST:0101234567"
        },
        "common_name": "CONG TY TNHH TEST",
        "organization": "CONG TY TEST",
        "tax_code": "0101234567",
        "citizen_id": null,
        "budget_code": null,
        "issuer": "C=VN, O=CONG TY TEST, CN=CONG TY TNHH TEST, UID=MST:0101234567",
        "serial_number": "1AE94B54DF7EA46919E9A2FF7E43594FE7431E2E",
        "not_before": "2026-11-15T16:03:53.000Z",
        "not_after": "2036-11-12T16:03:53.000Z",
        "valid_at_signing": null,
        "expired_now": false,
        "sha256_fingerprint": "4d323f124af82795da1738852ebec9c98f533dbf61e7a8e3eb4c67c8c9539490"
      },
      "chain": [
        {
          "subject": "CONG TY TNHH TEST",
          "issuer": "CONG TY TNHH TEST",
          "not_after": "2036-11-12T16:03:53.000Z",
          "signature_verified_by_issuer": true,
          "in_vn_ca_list": false,
          "trust_anchor": false
        }
      ],
      "trusted_root": false,
      "trusted_root_name": null,
      "covers_document_content": true,
      "status": "valid_untrusted"
    }
  ],
  "notes": [
    "Revocation (OCSP / CRL) is not checked.",
    "trusted_root: the certificate chains to a Vietnamese public CA listed by NEAC (rootca.gov.vn) or Ban Cơ yếu Chính phủ."
  ],
  "disclaimer": "Technical check only, not a legal validation of the document."
}
```

## Use cases

- Check that an incoming e-invoice XML was not edited after the seller signed it
- Verify XAdES signatures on Peppol / UBL invoices before booking them
- Debug signature errors of your own XML signing code (digest vs signature value)
- Audit which certificate and CA signed a batch of tax or insurance XML files

## FAQ

### Does "valid" mean the invoice is legally valid?

No. It means the XML is unchanged since signing and the signature matches the certificate. Legal validity also depends on the certificate status at signing time, the tax authority code and the content.

### Why valid_untrusted?

The signature is correct but the certificate does not chain to a CA in the Vietnamese public list (e.g. a self-signed or foreign certificate). Pass the expected certificate as cert to pin it.

### Is my XML stored?

No. The document is verified in memory and discarded after the response.
