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

# Validating from a script

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

`validate` checks against the system trust store and exits non-zero on anything a TLS client would reject:

```bash
y509 validate chain.pem                        # 0 = trusted
y509 validate example.com:443                  # also checks the hostname
y509 validate chain.pem --roots internal-ca.pem
```

| Outcome | Exit | Meaning |
| :--- | :--: | :--- |
| trusted | 0 | verifies against the trust anchors |
| self-anchored | 1 | links up, but its root is not trusted (an internal PKI, or a missing root) |
| broken | 1 | does not link up: expired, bad signature, missing issuer, wrong hostname |

Multiple targets are all checked before exiting; the exit is non-zero if any failed. With `--json`, a single target gives the usual object and several give `{"targets": [...]}`.

```bash
y509 validate www.example.com:443 api.example.com:443 smtp.example.com:587
```

`--policy fips` also checks the verified chain, root included, against the FIPS 140-3 approved algorithms, as a client in FIPS-only mode (`GODEBUG=fips140=only`, OpenSSL's FIPS provider) enforces them: RSA or ECDSA over SHA-256, SHA-384 or SHA-512, Ed25519, ML-DSA or SLH-DSA; ECDSA keys on P-256, P-384 or P-521; RSA keys of at least 2048 bits, an even size, with an odd public exponent above 65536. A trusted chain that breaks it exits 1.

`--policy pqc` requires post-quantum algorithms throughout the same chain: ML-DSA (FIPS 204) or SLH-DSA (FIPS 205) signatures, and ML-DSA, SLH-DSA or ML-KEM (FIPS 203) keys. Composite ML-DSA fails it. Go cannot verify an SLH-DSA signature, so a chain signed with one is reported broken.

```bash
y509 validate example.com:443 --policy fips
y509 validate chain.pem --roots root.pem --policy pqc
```

`--check-crl` fetches the CRL each certificate in the verified path points at, trust anchor excluded, checks it is signed by that certificate's issuer, and reports a certificate it lists. It is the only check that fetches something the server did not send, so it is opt-in, and it fills no gap: the chain is still judged as sent. Only HTTP and HTTPS distribution points are fetched, so `revocation.ok` means no finding rather than every certificate checked; `revocation.crl[].status` says which were. CRLs are cached under the user cache directory for up to an hour, never past their `nextUpdate`. Like a revoked staple, a revoked certificate does not change the exit status; gate on `revocation.ok`.

```bash
y509 validate example.com:443 --check-crl
```

## How the chain was served

Browsers fetch a missing intermediate from the AIA URL; `curl`, Go and Java do not. So a chain can verify and still be broken for clients. y509 reports that from what the server actually sent:

```text
$ y509 validate incomplete-chain.badssl.com:443
✅ Certificate chain is valid.
Trust anchor: ISRG Root X1

Chain as presented:
  • missing issuer: *.badssl.com
    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
    fetch from: http://yr2.i.lencr.org/
```

The chain verified (the macOS verifier fetched the intermediate) but is still misconfigured. y509 also reports redundant roots, wrong order, duplicates and unrelated certificates.

For the full result, including how the chain was served, see [machine-readable output](https://dyokto.github.io/y509/docs/json/).
