<!-- Generated by website/scripts/sync-docs.mjs from docs/guide/json.md. Edit that file, not this one. -->

# Machine-readable output

> Every page of this site: https://dyokto.github.io/y509/docs/llms.txt

`y509 <target> --json` prints the chain without a trust verdict:

```bash
y509 chain.pem --json | jq '.chain[0].otherNames'
```

`validate --json` prints the full result to stdout and nothing else. Errors go to stderr, so the output always parses. Exit codes are unchanged.

```bash
y509 validate example.com:443 --json | jq .
```

```json
{
  "host": "example.com",
  "trust": {
    "level": "self-anchored",
    "trusted": false,
    "anchor": "Internal Root CA",
    "error": "x509: certificate signed by unknown authority"
  },
  "presentation": {
    "ok": false,
    "findings": [
      {
        "problem": "missing issuer",
        "subject": "*.example.com",
        "detail": "the chain stops at a certificate that is not a CA; its issuer \"YR2\" was never sent, so a client that does not chase AIA (curl, Go, Java) cannot build a chain",
        "fetchUrls": ["http://yr2.i.lencr.org/"]
      }
    ]
  },
  "chain": [{ "index": 0, "commonName": "*.example.com", "daysUntilExpiry": 43, "…": "…" }],
  "connection": {
    "tlsVersion": "TLS 1.3",
    "cipherSuite": "TLS_AES_128_GCM_SHA256",
    "ocspStapled": true,
    "ocspStaple": {
      "status": "good",
      "serialNumber": "03d8…",
      "producedAt": "2026-09-14T09:00:00Z",
      "thisUpdate": "2026-09-14T09:00:00Z",
      "nextUpdate": "2026-09-21T08:59:59Z",
      "expired": false,
      "verified": true
    }
  },
  "conformance": { "ok": true, "findings": [] },
  "revocation": { "ok": true, "findings": [] },
  "advisories": []
}
```

- `chain` is in the order **presented**, not sorted.
- `level` and `problem` are strings; `findings` is always an array, never `null`.
- `connection` exists only for a live server, not a file or stdin.
- `ocspStaple` is what the server stapled. Nothing is fetched. No staple is not a finding.
  - `verified: false` on its own means the issuer was not in the chain. With `verifyError`, the issuer was there and the response did not verify.
  - No `nextUpdate` means the responder gave none: do not cache it.
  - If the staple was unreadable, `ocspStapleError` replaces `ocspStaple`. Only one of the two is ever present.
- `revocation` judges that staple, with its own `ok` so `presentation.ok` keeps its meaning. Present alongside `connection`, and for files too with `--check-crl`.
  - `problem` is one of `revoked`, `stale staple`, `staple not yet valid`, `unknown status`, `staple signature invalid`, `unreadable staple`, and with `--check-crl` `revoked in CRL`, `stale CRL`, `CRL signature invalid`, `CRL out of scope`, `CRL unavailable`.
  - `crl` is present only with `--check-crl`: one `{subject, url, status, cached, thisUpdate, nextUpdate, revokedAt, revocationReason, error}` per certificate checked, `status` being `good`, `revoked` or `unchecked` (with `error`). Empty when the chain is not trusted, since a CRL signature needs a trusted issuer to check against.
  - A signature left unchecked because the issuer was not sent is not a finding here. That is `missing issuer` under `presentation`.
- `conformance` checks each certificate against rules clients enforce on their own, with its own `ok`. Present for files too.
  - `problem` is one of `weak signature` (SHA-1 or MD5, except a genuine SHA-1 self-signature, which no client checks), `weak key` (RSA under 2048 bits), `no SAN` (a server certificate with a common name but no DNS, IP or URI SAN), `precertificate` (a CT precertificate was served), `unhandled critical extension` (a critical extension Go does not process), `insufficient SCTs` (below Chrome's CT policy).
  - `insufficient SCTs` counts only SCTs whose signature verifies against the log's bundled key, as Chrome does. It is judged by `validate` only, for a chain trusted through the system store that carries at least one SCT, embedded or sent in the TLS handshake. A certificate with none is not judged, because an enterprise root in the system store looks the same as a public one. Nor is one that falls short only by SCTs from logs the bundled list does not know, which could close the gap, or any chain once that list is more than 70 days old, which is when Chrome stops enforcing CT too. A scheduled workflow refreshes the list twice a month.
  - `conformance.ctPolicy` says how that went: `met`, `not met`, or `not judged: <reason>`, including why for a chain CT does not apply to, such as one trusted through `--roots`. `conformance.ok` is not affected by a check that was not judged, so a gate that must not pass an unjudged chain reads `ctPolicy` (the Action exposes it as `ct-policy`).
- `advisories` are notes on missing pointers, judged without verifying anything. They have no `ok` and fail no gate. Present for files too.
  - `problem` is `no AIA` (no CA Issuers URL) or `no CRL pointer` (neither a CRL distribution point nor an OCSP URL, on a certificate that is not short-lived). A missing OCSP URL alone is never reported. Self-signed certificates are skipped.
- `policy` is present only with `--policy`, as `{name, ok, findings}`. `problem` is `unapproved signature` or `unapproved key`.
- `chain[].noExpiry` is true for the RFC 5280 `9999-12-31` sentinel, a certificate with no well-defined expiration. `daysUntilExpiry` and `validityDays` still carry the real arithmetic, so read `noExpiry` before printing them.
- `chain[].scts` lists the embedded SCTs as `{logId, log, operator, logState, timestamp}`, with logs named from a bundled copy of Google's CT log list (`make ct-logs` refreshes it). Nothing is verified or fetched. `log`, `operator` and `logState` are absent for a log the list does not know. If the list is damaged, `sctError` says why and `scts` keeps what was read before the damage.
- `chain[].extensions` lists every extension as `{oid, name, critical}`. `name` is absent for one y509 does not know.
- `chain[].keyUsage` and `chain[].extKeyUsage` name the usages as RFC 5280 does (`digitalSignature`, `serverAuth`). An extended key usage y509 does not know is its OID. Absent when the certificate has none.
- `chain[].basicConstraints` is `{ca, pathLen}`. `pathLen` is absent when there is no limit and `0` when the CA may not issue further CAs. The whole object is absent when the certificate has no basic constraints extension.
- `chain[].subjectKeyId` and `chain[].authorityKeyId` are lowercase hex. A certificate's `authorityKeyId` matches its issuer's `subjectKeyId`.
- `chain[].caIssuers`, `chain[].ocspServers` and `chain[].crlDistributionPoints` are the AIA, OCSP and CRL URLs the certificate carries. Nothing is fetched.
- `chain[].idns` lists the internationalized names among the common name and `dnsNames` as `{ascii, unicode}`. For a name that fails IDNA validation, only the spelling the certificate carries is present and `error` says why. Absent when there are none.

The exit code alone cannot tell `self-anchored` from `broken`, or say anything about how the chain was served. JSON can:

```bash
# Fail the build on a chain that verifies but is mis-served.
y509 validate example.com:443 --json | jq -e '.presentation.ok'

# Warn 30 days out, without parsing prose.
y509 validate example.com:443 --json | jq '.chain[0].daysUntilExpiry < 30'

# Fail on a SHA-1 signature, a short RSA key, or a CN-only certificate.
y509 validate example.com:443 --json | jq -e '.conformance.ok'

# Fail on anything a FIPS-mode client would reject.
y509 validate example.com:443 --policy fips --json | jq -e '.policy.ok'

# Fail on any signature or key that is not post-quantum.
y509 validate example.com:443 --policy pqc --json | jq -e '.policy.ok'

# Fail on a revoked or stale stapled OCSP response.
y509 validate example.com:443 --json | jq -e '.revocation.ok'

# Find anything still negotiating below TLS 1.2.
y509 validate example.com:443 --json | jq -e '.connection.tlsVersion | test("1\\.[23]$")'
```
