---
title: "Verify with the CLI"
description: "Verify PDF-PQS signatures on any PDF from the command line using the Rust pdfpqs CLI."
---

> Documentation Index
> Fetch the complete documentation index at: https://pdf-pqs.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Verify with the CLI

The `pdfpqs` command-line tool runs all 12 steps of the [verification flow](https://pdf-pqs.org/concepts/verification-flow) and gives you a clear pass/fail verdict for the file along with the exact [result codes](https://pdf-pqs.org/tools/result-codes) for every signature inside it. You can use it interactively while developing, or integrate its JSON output into CI pipelines and backend verification scripts.

> **Version**
>
> The `pdfpqs` CLI is version 0.1.0, targeting `draft-laget-pdf-pqs-00`.

### Install

Install the CLI directly from GitHub with Cargo:

```sh
cargo install --locked --git https://github.com/pdf-pqs/pdf-pqs-rs pdfpqs
```

### Verify a file

By design, `pdfpqs verify` runs completely offline (it makes no network requests and does not read the PDF's Document Security Store). Pass in every trust anchor, intermediate certificate, CRL, and domain policy file you want it to evaluate. Use `--at` to check validity at a specific timestamp (if omitted, it uses the current system time).

```sh
pdfpqs verify contract-signed.pdf \
  --trust test-ca/certs/root.pem \
  --certs test-ca/certs/issuing.pem test-ca/certs/client-example.pem \
  --crl test-ca/crl/root.crl test-ca/crl/issuing.crl test-ca/crl/client-example.crl \
  --at 2026-12-15T00:00:00Z
```

```txt title="Output"
contract-signed.pdf: valid
  signature 1: place B, L = 1044: W_NO_TIMESTAMP
    signer: CN=Example Document Signer,O=Example Org,C=CA
```

You can rely on standard exit codes in scripts and CI pipelines:
- `0` for `valid` or `valid-domain-only`
- `1` for `invalid` or `no-signature`
- `2` for a command-line usage error or an unreadable file

If even a single byte inside `[0, L)` is altered after signing, verification fails immediately with `E_DIGEST_MISMATCH`:

```txt title="Output"
contract-tampered.pdf: invalid
  signature 1: place B, L = 1044: E_DIGEST_MISMATCH
    signer: CN=Example Document Signer,O=Example Org,C=CA
    detail: the SHA-512 of [0, L) differs from the message-digest attribute
```

### Options

| Option | What it does |
|---|---|
| `--trust <pem>...` | Root CA trust anchors you trust (PEM or DER; a single file can hold multiple certificates). |
| `--certs <pem>...` | Extra intermediate certificates used to complete the chain. These are not trusted on their own. |
| `--crl <crl>...` | Certificate Revocation Lists (PEM or DER) used to check whether any certificate in the chain was revoked. |
| `--policy <pdfpqs.json>...` | Local domain policy documents. Each file's `domain` field tells the CLI which domain it applies to. |
| `--resource <url>=<file>...` | Offline mappings for HTTPS certificate or CRL URLs referenced inside a policy document. |
| `--at <rfc3339>` | Fixed verification timestamp (RFC 3339 format), useful for test vectors and historical audits. |
| `--no-revocation` | Skips CRL revocation checks (step 9). Only use this for development chains that do not publish CRLs. |
| `--json` | Outputs a machine-readable JSON report instead of plain text. |

### Read the JSON report

With `--json`, the output matches the `expected` schema in the test vector manifest, plus helpful metadata like the signer's Distinguished Name and attachment filename:

```json title="Output"
{
  "result": "valid",
  "signatures": [
    {
      "place": "B",
      "L": 1044,
      "codes": ["W_NO_TIMESTAMP"],
      "signer": "CN=Example Document Signer,O=Example Org,C=CA",
      "attachment": "pdfpqs-1.p7s"
    }
  ],
  "fileCodes": []
}
```

### Sign in place B

For quick local tests, `pdfpqs` can also sign a PDF in Place B using a local ML-DSA private key (PKCS #8 PEM). Pass the signer certificate first, followed by any intermediate certificates in the chain:

```sh
pdfpqs sign --place b --key test-ca/keys/signer.key.pem \
  --cert test-ca/certs/signer.pem test-ca/certs/client-example.pem test-ca/certs/issuing.pem \
  contract.pdf contract-signed.pdf
```

```txt title="Output"
contract-signed.pdf: signed in place B, L = 1044
```

Want to extract and verify the raw CMS signature with OpenSSL instead? Follow the [OpenSSL guide](https://pdf-pqs.org/guides/openssl).

## Try it with a test vector

The fastest way to see `pdfpqs` in action without setting up your own certificates is to run one of the official test vectors:

1. Clone the `pdf-pqs/spec` repository, which includes ready-made signed PDFs and a test CA.
2. Open `vectors/manifest.json` and pick a vector to inspect its `inputs` object.
3. Pass each input to `pdfpqs verify` using the corresponding CLI flag:
   - `trustAnchors` -> `--trust` (root certificates you trust)
   - `certificates` -> `--certs` (untrusted intermediate certificates used to build the chain)
   - `crls` -> `--crl` (Certificate Revocation Lists)
   - `policyDocuments` -> `--policy` (domain `pdfpqs.json` files)
   - `resources` -> `--resource` (offline files mapped to policy URLs)
   - `validationTime` -> `--at` (the fixed timestamp used for repeatable testing)
4. Compare the CLI's `--json` output with the vector's `expected` block. The order of codes inside an array does not matter.

Here is a complete example using the `place-a` test vector:

```sh
pdfpqs verify vectors/files/place-a.pdf \
  --trust test-ca/certs/root.pem test-ca/certs/classical-root.pem \
  --certs test-ca/certs/issuing.pem test-ca/certs/client-example.pem test-ca/certs/tsa-ca.pem \
  --crl test-ca/crl/*.crl \
  --policy vectors/policies/example.com.json \
  --at 2026-12-15T00:00:00Z
```

```txt title="Output"
vectors/files/place-a.pdf: valid
  signature 1: place A, L = 1044: W_NO_TIMESTAMP
    signer: CN=Example Document Signer,O=Example Org,C=CA
```

In this output, the document is `valid` (the cryptographic signature, covered bytes, and certificate chain all check out) with one warning (`W_NO_TIMESTAMP`) because this particular test vector does not include an ML-DSA timestamp.

The Rust test suite executes all 33 vectors this way automatically, and `interop/run.sh` in `pdf-pqs/spec` verifies that files signed by the TypeScript library pass verification in the Rust CLI.

Browse the full set of cases on the [test vectors](https://pdf-pqs.org/tools/test-vectors) page.

Source: https://pdf-pqs.org/guides/verify-cli/index.mdx
