---
title: "Check a payload with OpenSSL"
description: "Extract and verify a PDF-PQS signature payload by hand using OpenSSL 4.1 and qpdf."
---

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

# Check a payload with OpenSSL

Because a PDF-PQS signature is a standard detached CMS `SignedData` structure (not a custom binary format), you do not need specialized PDF-PQS software just to confirm the cryptography works. You can extract the signature and verify it directly over the covered bytes using `openssl cms -verify -binary`.

To follow along, install **OpenSSL 4.1** (which includes ML-DSA support) and **qpdf** (for extracting PDF attachments).

### 1. Extract a place B signature payload

List the PDF's embedded attachments with `qpdf`, then save the `.p7s` signature file to disk:

```sh
qpdf --list-attachments signed.pdf
qpdf --show-attachment=pdfpqs-1.p7s signed.pdf > pdfpqs-1.p7s
```

Because a Place A signature lives inside an unsigned CMS attribute of a classical signature rather than as an attachment, `qpdf` cannot extract it. For Place A files, use `findPayloads` from the [TypeScript library](https://pdf-pqs.org/guides/sign-typescript) to get the raw DER bytes of each signature.

### 2. Read the covered byte length (L)

Inspect the CMS structure with OpenSSL to read the `pdf-byte-length` attribute (OID `1.3.6.1.4.1.99999.1.3`) and store its integer value in `L`:

```sh
openssl cms -cmsout -print -inform DER -in pdfpqs-1.p7s | grep -A2 '99999\.1\.3)'
L=$(openssl cms -cmsout -print -inform DER -in pdfpqs-1.p7s \
  | grep -A2 '99999\.1\.3)' | sed -n 's/.*INTEGER:\([0-9]*\).*/\1/p')
echo "$L"
```

### 3. Slice out the covered bytes

Copy the first `L` bytes of the PDF into `covered.bin` and double-check that the slice ends cleanly with `%%EOF`:

```sh
head -c "$L" signed.pdf > covered.bin
tail -c 8 covered.bin | od -c   # must end with %%EOF and an optional EOL
```

### 4. Verify the signature and certificate chain

Combine any intermediate CA certificates into `chain.pem`, then run `openssl cms -verify -binary` against `covered.bin`:

```sh
cat test-ca/certs/client-example.pem test-ca/certs/issuing.pem > chain.pem
openssl cms -verify -binary -inform DER -in pdfpqs-1.p7s \
  -content covered.bin \
  -CAfile test-ca/certs/root.pem -certfile chain.pem \
  -purpose any -attime 1797292800 \
  -out /dev/null
```

Here, `1797292800` is the Unix timestamp for `2026-12-15T00:00:00Z` (the fixed validation time used by the test vectors). When everything matches, OpenSSL prints `CMS Verification successful`. If even one covered byte was altered, OpenSSL prints `content verify error` and exits with a non-zero status.

## What OpenSSL does and does not check

OpenSSL is great for debugging, auditing, or proving to a security team that the signature uses standard CMS cryptography. It checks three core things: the SHA-512 content digest, the ML-DSA mathematical signature, and the X.509 certificate chain.

However, OpenSSL knows nothing about PDF structure or PDF-PQS policies, so it skips several checks from the full [verification flow](https://pdf-pqs.org/concepts/verification-flow):

- It does not confirm that `L` lands on a real PDF revision boundary (step 3).
- It does not enforce PDF-PQS algorithm restrictions such as rejecting ML-DSA-44 or HashML-DSA (step 2).
- It does not check certificate revocation unless you explicitly supply CRLs and enable CRL flags (step 9).
- It does not check Place A host boundaries, domain `pqcRequiredFrom` policies, or edits appended after `L` (steps 10 to 12).

Use OpenSSL for hands-on inspection and troubleshooting, and use a full PDF-PQS verifier (like the [CLI](https://pdf-pqs.org/guides/verify-cli)) whenever you need an authoritative verification decision.

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