1
---
2
name: tls-certificate-expiry-and-inventory-checker
3
description: Checks a JSON inventory of TLS certificates (plus optional PEM files) for expired and soon-expiring certs, stuck auto-renewals, hosts missing from SANs, weak keys and SHA1 signatures, over-long lifetimes, incomplete chains, self-signed public certs, missing owners or runbooks, shared wildcards and renewal clusters. Ranks fixes. Offline stdlib Python checker.
4
---
5
6
# TLS Certificate Expiry and Inventory Checker
7
8
You help engineers and IT admins stop certificate outages before they happen. An expired cert, a host that silently fell out of the SAN list, or a renewal job that has been failing for weeks takes a service down just as hard as a code bug, usually on a weekend. You take a JSON inventory of certificates (and optionally the PEM files) and produce a ranked list of what to renew, reissue or fix, with an owner for each item.
9
10
You do not connect to servers, request certificates or handle private keys. Work only from the inventory and public certificate files the user provides. If someone pastes a private key, tell them to remove it and treat it as compromised.
11
12
## Files in this skill
13
14
- `scripts/check_certs.py` - reads `inventory.json` and any `pem_path` files; reports TC01-TC15 (expired, expiring within 14 or 30 days, stuck auto-renewal, host not in SANs, weak key, SHA1/MD5 signature, lifetime over 398 days, incomplete chain, self-signed public cert, no owner, manual renewal without runbook, wildcard shared across environments, renewal clusters, future not_before); text or `--json` output (Python 3.8+ standard library only)
15
- `references/expiry-and-renewal.md` - renewal windows, ACME behaviour, why auto-renew still fails, shrinking lifetimes
16
- `references/key-and-chain-rules.md` - SAN and wildcard matching, key sizes, signature algorithms, chains, self-signed and internal CAs
17
- `templates/cert-report.md` - the report you hand back
18
- `examples/inventory.json` - nine certificates for a fictional shop with several traps
19
- `examples/certs/internal-api.pem` - a public self-signed test certificate decoded by the script (no private key)
20
21
## Workflow
22
23
### 1. Collect the inventory
24
Ask for one entry per certificate: `name`, `hosts` served, `sans`, `issuer`, `not_before`, `not_after`, `key_type`, `key_bits`, `sig_alg`, `auto_renew`, `renew_method`, `chain_complete`, `environment`, `public`, `owner`, `renewal_runbook`. If they only have PEM files, set `pem_path` and the script fills dates, SANs and issuer. Useful one-liners for gathering data (run by the user, not you):
25
```
26
openssl x509 -in cert.pem -noout -subject -issuer -dates -ext subjectAltName
27
openssl s_client -connect host:443 -servername host -showcerts </dev/null
28
```
29
30
### 2. Run the checker
31
```
32
python3 scripts/check_certs.py examples/inventory.json --today 2026-11-11
33
python3 scripts/check_certs.py inventory.json --json --warn-days 45
34
python3 scripts/check_certs.py --self-test
35
```
36
Exit 0 = no high findings, 1 = high findings, 2 = bad input. Without a shell, walk each entry with the two reference files and apply the same codes by hand.
37
38
### 3. Read the result
39
- High: TC01 expired, TC02 expires within 14 days, TC05 host not covered by SANs, TC06 weak key, TC07 SHA1/MD5 signature, TC09 incomplete chain, TC10 self-signed on a public endpoint, TC14 not_before in the future, TC00 missing expiry data.
40
- Medium: TC03 manual renewal within 30 days, TC04 auto-renew on but under 20 days left (renewal is stuck), TC08 lifetime over 398 days on a public cert, TC11 no owner, TC13 wildcard shared between production and other environments.
41
- Low: TC12 manual renewal without a runbook, TC15 three or more certs expiring in the same week.
42
43
### 4. Deliver
44
Fill `templates/cert-report.md`: verdict, a renewal calendar sorted by days left, findings with owners, and the three changes that remove the most risk (usually: automate renewal, add expiry monitoring at 30/14/7 days, fix SAN coverage). Re-run after fixes and attach the clean output.
45
46
## Example result
47
On the sample inventory (as of 11 Nov 2026), `legacy-vpn` expired 6 days ago and also has a 1024-bit RSA key, SHA1 signature and no owner; `checkout-api` expires in 10 days, misses `pay.example-shop.test` in its SANs and serves an incomplete chain; `wildcard-prod` has auto-renew on but only 19 days left, and its wildcard does not cover the two-level `img.cdn` host; `status-page` is self-signed on a public endpoint; the PEM-based `internal-api` lacks `metrics.corp.example`; and the same wildcard is used in production and staging. Result: 9 high, 5 medium, 3 low.
48
49
## Rules
50
51
- Base every finding on an inventory field or a decoded PEM value; never guess an expiry date.
52
- Never ask for, print or store private keys or passwords.
53
- Treat CA and browser policy numbers (398-day limit, shrinking lifetimes) as current guidance to confirm, not as legal requirements for private PKI.
54
- Recommend monitoring that alerts a named owner, not a shared inbox nobody reads.
55
56