---
title: "Certificates and TLS"
description: "Inventory the TLS certificates your endpoints, clouds and Kubernetes clusters hold, check each one, and watch Certificate Transparency for your domains."
keywords: ["certificate expiry", "TLS", "network range sweep", "CIDR", "STARTTLS", "SSH key exchange", "certificate inventory", "Kubernetes TLS Secrets", "cert-manager", "Istio", "Linkerd", "service mesh certificates", "pipeline gate", "CAA", "47-day certificates", "certificate monitoring", "GitHub Action", "AWS Certificate Manager", "Azure Key Vault certificates", "Google Certificate Manager", "Certificate Transparency", "crt.sh"]
---

The **Certificates** page lists every TLS certificate your endpoints serve and
your cloud certificate services and Kubernetes TLS Secrets hold, when each
expires, and where it is served or held, and files a finding for anything wrong
with it. Endpoints are re-checked once a day; cloud and cluster certificates at
each collection of their account or cluster.
For the domains you have verified, it can also watch public Certificate
Transparency logs for certificates you did not expect. Each certificate carries
a [post-quantum readiness](/configuration/pqc-readiness) score, and the same
verified domains get [email DNS checks](/configuration/email-dns) (SPF, DMARC,
DKIM, null MX).

The **Source** filter narrows the list to one place: Added, DAST, Kubernetes
(Ingress hosts and TLS Secrets), Network range, ACM, Key Vault, Google, or CT log (which shows the certificates seen in CT
logs instead, see [below](#certificate-transparency-monitoring)).

## Where endpoints come from

| Source | How it gets on the list | Findings |
|---|---|---|
| **Added** | **Certificates → Add endpoint**, or `POST /api/v1/certificates/endpoints` with `host`, `host:port` or an `https://` URL (port 443 when none is given) | On its own asset (kind `tls_endpoint`), as misconfiguration findings |
| **DAST target** | Every `https` [DAST target](/configuration/dynamic-scanning), on each daily pass | Filed by the target's DAST scans, which run the same checks except CAA; the inventory only records the certificate |
| **Kubernetes Ingress** | The hosts in `spec.tls` of every Ingress in a [connected cluster](/configuration/cloud-and-kubernetes), after each complete collection | On its own asset, as for an added endpoint |
| **Network range** | Every address and port of a [network range](#network-ranges) that completes a handshake, on the range's daily sweep | On its own asset, as for an added endpoint, without the host-name check |

For a Kubernetes Ingress, TRUSTIVAN reads the host names and the **name** of
the TLS Secret from the Ingress, and the certificate is fetched from the host
with a handshake like any other endpoint. Reading the Secret itself is a
separate, optional step ([below](#kubernetes-tls-secrets-and-cert-manager)). A wildcard host (`*.example.com`) has no
one host to connect to and is skipped. When an Ingress drops a host, or a DAST
target is removed, its endpoint goes too; a range's endpoints go with the range
or when a sweep no longer finds them. An endpoint you added is removed with
**Remove**, which also archives its asset and so takes its findings out of the
backlog.

An organization can have at most 500 endpoints, and each daily pass checks at
most 50 per organization, oldest first, so a large list is covered over
several passes.

## Cloud certificate services

Each collection of a [connected cloud account](/configuration/cloud-and-kubernetes)
also reads the certificates its certificate service holds:

| Source | What is read | Permission |
|---|---|---|
| **ACM** | Issued certificates of every key type in each region the account names: `ListCertificates`, then `GetCertificate` (the certificate and its chain) | `acm:ListCertificates`, `acm:GetCertificate`, in the [generated policy](/configuration/cloud-posture#aws) |
| **Key Vault** | Each vault's enabled certificates on the vault's data plane; `cer` is the public certificate | **Key Vault Reader**, or an access policy with certificate List and Get ([details](/configuration/cloud-posture#azure)) |
| **Google** | Certificate Manager certificates (every location) and Compute Engine SSL certificates (global and regional) | Within **roles/viewer** |

No private key is ever read: ACM's `ExportCertificate` is never called, Key
Vault's secret behind a certificate is never requested, and Google's APIs do
not return keys. Each certificate is stored like an endpoint's and judged by
the same checks, without the three that need a handshake (host name, TLS 1.0/1.1,
CAA). A Key Vault certificate is stored without its chain, so its chain and its
lifetime are not judged. Its findings hang on a `cloud_resource` asset for the
certificate, linked under the account. A certificate a complete run no longer
sees leaves the inventory and its asset is archived; a run that could not read
certificates (a missing grant, an API not enabled) removes nothing and shows a
gap for the certificate kind on the account's posture, without making the
posture run partial. At most 500 certificates are read per account and run
(per region on AWS).

## Kubernetes TLS Secrets and cert-manager

Each collection of a [connected cluster](/configuration/cloud-and-kubernetes)
can also read the certificates the cluster holds. The findings hang on one
`kubernetes_certificates` asset per cluster (named "*cluster* certificates"),
each located at *cluster*/*namespace*/*name*.

| Source | What is read | Grant | Default |
|---|---|---|---|
| **cert-manager** | Every `Certificate` (secretName, issuerRef, status.notAfter, status.renewalTime, the Ready condition), `Issuer` and `ClusterIssuer` (the Ready condition), API group `cert-manager.io/v1` | `get`, `list` on `certificates`, `issuers`, `clusterissuers` in `cert-manager.io`, in the ClusterRole the **Connect cluster** dialog shows | Read on every collection |
| **TLS Secrets** | Secrets of type `kubernetes.io/tls` (the list asks the API server for that type only), and of each one the certificates in `tls.crt` | `list` on `secrets`, the separate optional ClusterRole in the dialog | Off |
| **Service mesh trust roots** | The ConfigMaps Istio (`istio-ca-root-cert`, key `root-cert.pem`) and Linkerd (`linkerd-identity-trust-roots`, key `ca-bundle.crt`) publish their root CA certificates in, listed by name across the cluster; only those two keys are decoded | `get`, `list` on `configmaps` with `resourceNames: [istio-ca-root-cert, linkerd-identity-trust-roots]`, in the ClusterRole the dialog shows; no other ConfigMap and no Secret | Read on every collection |

A cluster without cert-manager answers that the API group does not exist, and
nothing is reported for it. The cert-manager checks:

| Check | Severity | What fails it |
|---|---|---|
| `cert-manager-certificate-not-ready` | medium | A Certificate's Ready condition is False; the evidence carries cert-manager's reason and message |
| `cert-manager-renewal-overdue` | medium | A Certificate's status.renewalTime is more than an hour in the past: cert-manager moves it forward when a renewal succeeds |
| `cert-manager-issuer-not-ready` | medium | An Issuer's or ClusterIssuer's Ready condition is False |

A Certificate's status.notAfter is also judged by the expiry checks
(`tls-certificate-expired`, `tls-certificate-expiring`, with your thresholds)
when its Secret was not read; when it was, the certificate in the Secret is
judged instead, so the same expiry is not reported twice.

**Why reading TLS Secrets is off by default.** Kubernetes RBAC cannot grant a
Secret's certificate without its private key, or Secrets of one type without
every other: `list secrets` is read access to every Secret in scope, keys,
tokens and passwords included, and the API server returns them whole. So the
default ClusterRole does not grant it, and the collector asks for Secrets only
when both the optional grant is applied **and** reading is turned on for the
cluster (**Kubernetes → *cluster* → TLS Secrets → Read TLS Secrets**, or
`PUT /api/v1/kubernetes/clusters/{id}/tls-secrets` with `{"enabled": true}`,
`credentials:manage`). A credential that could already read Secrets (a broad
token) is not used to unless the setting is on. To narrow the grant, bind the
optional ClusterRole with RoleBindings in the namespaces you choose instead of
the ClusterRoleBinding.

When TRUSTIVAN does read them, it decodes only `tls.crt` from each Secret:
`tls.key` and every other data key are skipped unparsed, nothing of them is
stored or logged, and from `tls.crt` only `CERTIFICATE` blocks are kept, so a
private key pasted there by mistake is dropped. The trade-off of leaving it off:
the Certificates page lists an Ingress certificate only through its handshake,
and a certificate no Ingress serves (a webhook's, an internal service's, one
mounted into a pod) is seen only through cert-manager's status, without its key
type, signature or chain.

Each TLS Secret's certificate is stored like a cloud certificate, held at
*cluster*/*namespace*/*secret*, and judged by expiry, weak key and weak
signature. Its chain is not judged: what in-cluster clients trust is often a
private CA, which a chain to a public root says nothing about. A Secret a
complete read no longer sees leaves the inventory; turning the setting off
empties the cluster's Secrets from it at the next collection and resolves their
findings. A source the credential is refused, or a cluster with more than 500
TLS Secrets or cert-manager Certificates, resolves nothing and removes nothing,
and shows on the cluster's posture page as a source that was not read.

### Service mesh trust roots

A mesh's root CA signs every workload certificate in it, so when it expires
mutual TLS stops across the mesh. Each root certificate in the two ConfigMaps
is added to the inventory once (Istio copies its ConfigMap into every
namespace; the first one is named), with source **Service mesh** (`mesh`),
held at *cluster*/*namespace*/*configmap*, and judged by expiry (your
thresholds), weak key and weak signature. Like a TLS Secret's, it is not
judged against public roots: a mesh root is self-signed and only the mesh
trusts it. Its findings hang on a second asset per cluster, "*cluster* mesh
trust roots", so a cluster whose role cannot read the ConfigMaps (one connected
with the ClusterRole published before 2026-11-19) shows `mesh` as not read and
changes nothing else. Only the public certificates are read: the roots'
private keys (Istio's `cacerts` Secret, Linkerd's issuer Secret) are never
asked for. A mesh that keeps its root elsewhere (an external CA, Istio with a
custom CA that publishes no root ConfigMap) is not seen. Workload leaf
certificates, which live in memory in each proxy, are not read.

## Network ranges

To find certificates nobody listed, add a block of addresses under
**Certificates → Network ranges → Add range** or `POST /api/v1/certificates/ranges`
with `cidr` and, optionally, `ports` and `protocols`:

- **Size.** At most 1024 addresses: an IPv4 `/22` or smaller, an IPv6 `/118` or
  smaller, written from its first address (`203.0.112.0/22`, not `203.0.113.0/22`).
  At most 10 ranges per organization.
- **Ports.** Up to 10. Left out: 443, 8443, 636 (LDAPS), 993 (IMAPS), 995
  (POP3S) and 465 (SMTPS). Ports 25, 587, 143, 110, 389, 21 and 5222 are
  upgraded with STARTTLS, and 22 is read as SSH ([below](#other-protocols)).
- **Protocols.** For a service on another port, name its protocol: `2525/smtp`
  or `2222/ssh` in the Ports field, or `"protocols": {"2525": "smtp"}` in the
  API (one of `smtp`, `imap`, `pop3`, `ldap`, `ftp`, `xmpp`, `ssh`, for a port
  in the list). The endpoints found there keep it.
- **Ownership.** One of your [DAST targets](/configuration/dynamic-scanning)
  whose ownership is verified must serve its verification file
  (`/.well-known/trustivan-verification.txt`, holding `trustivan-verify=` and
  the target's token, as for the file method) from an address inside the range.
  TRUSTIVAN connects to that address itself, not to wherever the name resolves,
  and asks for the file under the target's host name, following no redirect.
  The address tried is the target's IP address, or each address its host name
  resolves to that falls in the range. A DNS TXT record alone does not count:
  it proves you control a name, and a name can point at anyone's addresses.
  This proves you run a host in the range, not that you hold every address in
  it, which is why ranges are small and the sweep is only the passive handshake
  below. A refusal names each address tried and what it answered.
- **Reach.** Sweeps run from TRUSTIVAN's own servers, so every address in the
  range must pass the same guard as an endpoint: a private, loopback,
  link-local (cloud metadata), carrier-grade NAT or reserved range is refused,
  unless the deployment allows private DAST targets (`DAST_ALLOW_PRIVATE_TARGETS`,
  for a self-hosted install inside your network). There is no in-network
  scanner to reach private ranges from inside.

Both rules are checked when the range is added and again before every sweep,
so the file must stay published; a range that no longer passes is not swept
and says why. A new range is swept
on the next hourly pass, then once a day, one range per organization per pass.
A sweep opens at most 100 new connections a second and 32 at once, gives each
three seconds, and keeps only the addresses and ports that complete a TLS
handshake in the port's protocol (or, for SSH, send an algorithm list); a closed port or a plain-HTTP
service is not kept. What it keeps becomes an endpoint with source `network`,
checked with the others. A certificate found by address is not judged against a
host name, since no client asked for one. A sweep where nothing answers keeps
the endpoints found before, as more likely a network problem than every service
gone. Found endpoints count toward the 500-endpoint limit; beyond it, they are
not added. **Remove** on a range stops the sweeps and removes its endpoints.

## How a certificate is read

A check is a series of **passive handshakes**: TRUSTIVAN connects and completes
a TLS handshake offering every version from 1.0 up, which fetches the
certificate, then [enumerates the cipher suites](#cipher-grading) the server
accepts. No HTTP request is sent, so no proof of ownership is asked for. Only
the public certificates the server sends are read; nothing can read a private
key this way.

Connections go through the same guarded dialler as dynamic scans: an address
that resolves to a private, loopback or link-local range is refused unless the
deployment allows private DAST targets (`DAST_ALLOW_PRIVATE_TARGETS`). For a
host name, CAA records are looked up through the server's resolver.

A check that cannot complete (the host does not answer, or does not speak TLS)
records why on the endpoint and changes nothing else: the last certificate and
its open findings stay as they were.

Each handshake has 10 seconds, and a whole check 20 seconds (SSH: the
algorithm list and every host-key exchange together). A check that runs out of
time during cipher enumeration still records the certificate and judges it; the
suites seen so far are kept, the grade is shown as **not every suite tried in
time**, and no open finding is resolved by that check, since what it did not
reach it did not look at. In the daily sweep each organization's endpoints get
at most five minutes per hourly pass; those left over are checked first on the
next pass.

TRUSTIVAN stores, per certificate: SHA-256 fingerprint, subject and common name,
subject alternative names, issuer, serial number, key type and size, signature
algorithm, validity dates, whether it is self-signed, and the chain the server
sent. Never a private key.

### Cipher grading

For each of TLS 1.0, 1.1 and 1.2, the probe offers every cipher suite Go's TLS
client implements, notes the one the server picks, takes it out of the offer
and asks again, until the server refuses. The result is the list of suites the
server accepts at that version, in the order it prefers them: one handshake per
accepted suite, plus one per version. A TLS 1.3 client cannot narrow its suites
(all three are AEAD), so one TLS 1.3-only handshake records whether 1.3 is
accepted and the suite chosen. Suites Go does not implement (DHE, CAMELLIA,
ARIA, NULL, EXPORT, SSL 3.0) are never offered, so a server that accepts only
those is not seen accepting them.

When the check's 20 seconds run out first, the version it stopped at and every
later one are marked `incomplete` in `cipher_suites`, and the grade is of the
suites seen: the ones not tried can only lower it.

The endpoint gets a **cipher grade** from what was accepted. The rule is
TRUSTIVAN's own, not an industry score; the worst line that applies decides:

| Grade | When |
|---|---|
| F | An RC4 or 3DES suite is accepted at any version |
| C | TLS 1.0 or 1.1 is accepted |
| B | At TLS 1.2, a suite without ECDHE forward secrecy (`TLS_RSA_WITH_*`) or without AEAD (a CBC mode) is accepted |
| A | None of these: only ECDHE suites with AES-GCM or ChaCha20-Poly1305 at TLS 1.2, and/or TLS 1.3 |

The grade judges protocol versions and suites only; the certificate has its own
checks below. F, C and suites without forward secrecy also raise findings
(`tls-weak-cipher`, `tls-legacy-protocol`, `tls-cipher-no-forward-secrecy`); CBC
suites with ECDHE lower the grade to B without a finding, since many load
balancers keep them for older clients. The grade and the accepted suites are
on the endpoint (`cipher_grade`, `cipher_suites` in the API) and in the
[tls-check](#the-tls-check-github-action) output.

### Other protocols

On the well-known plaintext ports of mail, directory, file-transfer and chat
services, the probe asks for TLS first, on every connection, and then
handshakes as above: SMTP `STARTTLS` on 25 and 587 (after `EHLO`), IMAP
`STARTTLS` on 143, POP3 `STLS` on 110, the LDAP StartTLS extended operation on
389, FTP `AUTH TLS` on 21 (RFC 4217), and XMPP client `<starttls/>` on 5222
(RFC 6120, the stream opened to the endpoint's host name; an address a range found is sent as is, which a server may refuse). No login is
attempted, no mail is sent and no file command is given. A server that refuses
the upgrade is recorded as a check that could not complete.

For one of these services on another port, name the protocol in the address:
`smtp://mail.example.com:2525`, `imap://`, `pop3://`, `ldap://`, `ftp://` or
`xmpp://` (the port defaults to the protocol's own when left out), and
`ssh://host:2222` for SSH. Ranges name it per port. Without a name, any other
port is spoken to as TLS from the first byte. RDP is not checked.

SSH (port 22, or a port named `ssh`) has no certificate. The probe sends its
SSH version line and reads the server's first packet (`SSH_MSG_KEXINIT`), which
lists every key exchange, host key, cipher and MAC algorithm the server
accepts. It then runs the key exchange once for each host key type offered
(Ed25519, each ECDSA curve, RSA, DSA; at most six) and hangs up as soon as the
server has signed it with that key, before authentication: no login is
attempted and no channel opened. Each host key's type, size and SHA256
fingerprint (as `ssh-keygen -l` prints it) is recorded on the endpoint
(`ssh_host_keys`) and shown under its address. The next check compares them: a
key type whose fingerprint differs raises `ssh-host-key-changed`, which
resolves at the check after, which treats the new key as the known one. A type
that appears or disappears is not a change, and a check that reads no key keeps
the ones recorded. The `ssh-` checks below judge the list and the keys; the
endpoint has no certificate in the inventory.

## The checks

Each is listed with what, why and how to fix in the [check catalogue](/concepts/check-catalogue)
(area `tls`), and has its own page at [trustivan.com/checks](https://trustivan.com/checks/).

| Check | Severity | What fails it |
|---|---|---|
| `tls-certificate-expired` | high | The leaf's notAfter has passed |
| `tls-certificate-not-yet-valid` | high | The leaf's notBefore is in the future |
| `tls-certificate-expiring` | low / medium / high | Fewer days left than the organization's thresholds: 30, 14 and 7 by default |
| `tls-certificate-hostname` | high | The host name is not among the certificate's subject alternative names |
| `tls-certificate-untrusted` | medium | The chain the server sends does not reach a trusted root. The evidence says whether the intermediate is probably missing (the server sent the leaf only) or the certificate is self-signed |
| `tls-certificate-weak-key` | high | RSA under 2048 bits, an elliptic curve under 256 bits, or DSA, on the leaf or an intermediate |
| `tls-certificate-weak-signature` | medium | The leaf or an intermediate is signed with SHA-1 or MD5 |
| `tls-legacy-protocol` | medium | A TLS 1.0 or TLS 1.1 handshake completes |
| `tls-weak-cipher` | medium | An RC4 or 3DES suite is accepted at TLS 1.0, 1.1 or 1.2 |
| `tls-cipher-no-forward-secrecy` | low | A suite with RSA key exchange (`TLS_RSA_WITH_*`) is accepted |
| `tls-caa-missing` | low | No CAA record on the host name or any parent below the top-level domain |
| `tls-certificate-long-lifetime` | low | A publicly trusted certificate issued for more than 90 days |
| `ssh-weak-key-exchange` | medium | The SSH server offers diffie-hellman-group1-sha1, diffie-hellman-group14-sha1, diffie-hellman-group-exchange-sha1 or rsa1024-sha1 |
| `ssh-weak-host-key` | medium | The SSH server offers ssh-dss or ssh-rsa (SHA-1) host key signatures |
| `ssh-weak-cipher` | low | The SSH server offers a CBC or arcfour cipher, `none`, or an MD5 or 96-bit MAC |
| `ssh-host-key-short` | medium | A host key the server signs with is DSA, or RSA under 2048 bits |
| `ssh-host-key-changed` | medium | A host key type's SHA256 fingerprint differs from the previous check's |

`tls-certificate-long-lifetime` is **47-day readiness**. The CA/Browser Forum's ballot SC-081 cuts
the longest lifetime of a public TLS certificate to 200 days from March 2026,
100 from March 2027 and 47 from March 2029. A certificate issued for longer than
90 days is almost always renewed by hand, and a manual process will not keep up
with a renewal every few weeks; the fix is an automated (ACME) issuer.

Change the thresholds with **Certificates → Expiry thresholds** or
`PUT /api/v1/certificates/settings` (`1 <= high <= medium <= low <= 365`). The
next check of each endpoint uses them. DAST scans use the defaults.

What the checks do not do: offer suites Go does not implement (above), test for
protocol attacks (Heartbleed, ROBOT, renegotiation, downgrade; no attack payload
is ever sent), check RDP, fetch a missing intermediate from its AIA URL, or
check revocation (OCSP, CRL). A chain is judged against the server's trust
store, so an internal certificate from your own CA reads as untrusted:
suppress that finding with the reason.

## Findings and alerts

A failed check is an ordinary finding: kind `misconfiguration`, rule the check
id, on the endpoint's asset, through the same lifecycle as a scan's findings.
It shows on **Findings**, can be triaged and suppressed, resolves on the first
check that no longer fails it, and changes of state publish
`finding.state_changed` to webhooks. A **new** critical or high finding is
announced to the destinations that receive new critical or high findings from
scans (**Settings → Notifications**), with the same wording.

## Certificate Transparency monitoring

Every publicly trusted certificate is published in Certificate Transparency
(CT) logs. For each host of a [DAST target](/configuration/dynamic-scanning)
whose **ownership you have verified**, TRUSTIVAN asks a public CT search once a
day which unexpired certificates were logged for the host and its subdomains,
and keeps them, one per serial number and issuer (a precertificate and its
certificate are one). Nothing else is ever searched: a name you type into the
settings is a name you expect, not one TRUSTIVAN looks up. When a target is
deleted or its verification lapses, its domain and the certificates seen for it
are removed and its asset is archived.

Two checks run on each logged certificate:

| Check | Fails when | Severity |
|---|---|---|
| `ct-unexpected-issuer` | The issuer is not on your **allowed issuers** list (matched case-insensitively as part of the issuer's name, e.g. `Let's Encrypt`, `DigiCert`). An empty list judges no issuer. | High |
| `ct-unexpected-name` | A name on it is a wildcard, or a subdomain you do not know: not the verified host, not in your **expected names**, not an endpoint TRUSTIVAN checks, and not a name on a certificate in the inventory. | Medium |

Set both lists under **Certificates → Certificate Transparency** (or
`PUT /api/v1/certificates/settings` with `ct`). An expected name is a host name
or `*.domain`, which expects that wildcard and every name one label under the
domain. Findings hang on a `certificate_domain` asset per monitored domain and
follow the usual lifecycle: expecting a name resolves its findings at the next
search.

**It is off by default.** The operator turns it on with
`CT_MONITORING_ENABLED=true`. Each search is an outbound HTTPS request carrying
the domain name to `CT_SEARCH_URL` (`https://crt.sh` by default, or any service
answering crt.sh's JSON), bounded by `CT_SEARCH_TIMEOUT` (30 seconds) and made
through the same SSRF-guarded transport as webhooks; allow egress to that host.
Each hourly pass searches at most 10 domains per organization, longest-waiting
first. A search that fails is recorded on the domain and changes nothing else.
At most 2,000 certificates are kept per domain search.

## API

All under `/api/v1`, described in the [API reference](/api-reference/overview):

| Route | Permission |
|---|---|
| `GET /certificates?status=expired\|expiring\|valid&source=manual\|dast\|kubernetes\|network\|acm\|keyvault\|google\|mesh&q=&pqc=now\|2030\|2035\|renewal\|unknown` | `assets:read` |
| `GET /certificates/endpoints`, `GET /certificates/settings`, `GET /certificates/ct`, `GET /certificates/pqc`, `GET /certificates/email-dns`, `GET /certificates/ranges`, `GET /certificates/gates` | `assets:read` |
| `POST /certificates/endpoints`, `DELETE /certificates/endpoints/{id}`, `POST /certificates/ranges`, `DELETE /certificates/ranges/{id}`, `PUT /certificates/settings` | `assets:write` |
| `POST /certificates/endpoints/{id}/check`, `POST /certificates/gates` | `scans:create` |

## The tls-check GitHub Action

The same checks run in CI with no TRUSTIVAN account. The runner shakes hands
with each host itself and sends nothing to TRUSTIVAN unless you turn on
[`upload`](#send-gate-results-to-the-inventory):

```yaml
- uses: trustivan/trustivan/actions/tls-check@v1
  with:
    hosts: |
      shop.example.com
      api.example.com:8443
    fail-on: medium   # low, medium, high or never
```

It fails the job when a host has a finding at `fail-on` or above or cannot be
checked, writes a table to the job summary, and annotates each problem. Its
inputs and limits are in `actions/tls-check/README.md`. From a shell,
`go run ./cmd/tls-check host ...` in `backend/` does the same.

### Gate a certificate before it is deployed

With `files`, the action judges certificates in the repository instead of (or
as well as) live hosts, so a bad certificate fails the pull request that would
deploy it. It reads three kinds of file:

- a PEM file (a leaf, or a leaf with its chain); a private key in it is refused;
- a Kubernetes TLS Secret manifest, from its `tls.crt` (`data` or `stringData`);
  `tls.key` is skipped, never decoded;
- a cert-manager `Certificate` manifest. Nothing is issued yet, so what it asks
  for is judged: `privateKey` (RSA-2048 when unset), `duration` (90 days when
  unset), `dnsNames`, `ipAddresses`, `commonName` and `issuerRef`. An issuer can
  issue for less than the duration asked, as Let's Encrypt does.

A certificate gets the inventory's checks (expiry tiers, weak key, SHA-1 or MD5
signature; the chain and the 90-day lifetime only for a bundle, judged against
the runner's roots plus `ca-file`) and its [post-quantum readiness](/configuration/pqc-readiness)
score, then the policy you set. Each policy rule that fails is a high finding:

| Input | Default | Fails when |
|---|---|---|
| `keys` | `RSA-2048,ECDSA-256,Ed25519` | the key type is not listed or is smaller than its size |
| `min-pqc-score` | `0` (off) | the score is below it; a classical certificate scores at most 60 |
| `max-validity-days` | `0` (off) | the certificate is valid for longer |
| `names` | | a name is not covered (a wildcard covers one label) |
| `issuers` | | the issuer's name contains none of them; for a cert-manager `Certificate` they are matched against `Kind/name` of its `issuerRef` |

```yaml
- uses: actions/checkout@v4
- uses: trustivan/trustivan/actions/tls-check@v1
  with:
    files: |
      deploy/k8s/*.yaml
      certs/edge.pem
    max-validity-days: "90"
    min-pqc-score: "40"
    names: shop.example.com
    issuers: ClusterIssuer/letsencrypt-prod, Let's Encrypt
```

Annotations point at the file. It issues nothing, and nothing is sent to
TRUSTIVAN unless you turn on `upload`.

### Send gate results to the inventory

With `upload: "true"` and an API key holding `scans:create` (the scope a CI key
for scans already has), the action also posts the run's result to
`POST /api/v1/certificates/gates` with the repository, ref, commit and a link
to the run:

```yaml
- uses: trustivan/trustivan/actions/tls-check@v1
  with:
    files: deploy/k8s/*.yaml
    upload: "true"
    api-key: ${{ secrets.TRUSTIVAN_API_KEY }}
```

From a shell, `tls-check -upload` reads `TRUSTIVAN_API_KEY` and
`TRUSTIVAN_URL`, and the repository, ref, commit and run link from GitHub
Actions or GitLab CI variables. `TRUSTIVAN_URL` must be `https://`; plain
`http://` is accepted only for `localhost` or a loopback address, since the API
key travels in a request header. A run that cannot be uploaded fails the step.

Each run shows under **Certificates → Pipeline gates** (pass or fail, the
hosts and files that failed and why), and on every certificate in the inventory
whose SHA-256 the run judged, as its three newest gate results. A certificate
judged only in the pipeline is not added to the inventory; it appears there
once it is served, synced from a cluster or held by a cloud service. A run is
what the pipeline reported: TRUSTIVAN stores it within bounds (512 KiB, 500
results, 32 findings per result) and does not re-judge it. An organization
keeps its newest 500 runs.

## What is verified, and how

The checks are tested against generated certificates (expired, not yet valid,
three expiry tiers, mismatched, RSA-1024, SHA-1, leaf-only chain, private root,
398-day lifetime) and local TLS servers (TLS 1.2 only, TLS 1.0 accepted, RC4
accepted, CBC and RSA key exchange accepted, each graded); STARTTLS against
local SMTP, IMAP, POP3, LDAP, FTP and XMPP listeners that accept and refuse the
upgrade, on their own ports and on named ones; the SSH read against a local
`golang.org/x/crypto/ssh` server with modern and weak algorithm lists, Ed25519
and 1024-bit RSA host keys, and a host key replaced between checks; range discovery against local
listeners (TLS, plain HTTP, closed); CAA against a local DNS server. None of the
protocol checks or range sweeps has been run against a production mail server,
directory or network. The cloud reads are tested against recorded
ACM, Key Vault, Certificate Manager and Compute responses, the cluster reads
against recorded API-server responses (cert-manager present, absent and
refused; TLS Secrets with a stray key block and the type filter; mesh
ConfigMaps by name, refused, and Istio's per-namespace copies), and CT monitoring
against a recorded crt.sh response; none has been run against a live
account, cluster or the live crt.sh. The inventory, findings, sweeps and API are tested
against PostgreSQL. The pre-deployment gate is tested against generated PEM
files and bundles and against Secret and cert-manager `Certificate` manifests;
the upload against a local server, and the gate routes (401, 403 without
`scans:create`, 413, validation, one tenant's runs invisible to another)
against PostgreSQL.
None of this has been run against a production estate yet.

Not built: issuing or renewing certificates, CT monitoring of names other than
verified DAST hosts, and certificates held outside the three services (App
Service certificates, for example).
