brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: openssl verify -untrusted checks a certificate chain before you install it

Openssl
~/tips/tip-openssl-verify-untrusted-chain

openssl verify -show_chain -CAfile root.pem -untrusted intermediate.pem cert.pem

Checks whether a certificate and its intermediates form a valid chain before you deploy them.

A certificate that works fine in your desktop browser and fails on a phone, in curl or in some Docker container usually has one problem: the intermediate certificate is missing. Browsers sometimes hide that. openssl verify doesn’t, which is why I’d run it on the files before they go anywhere near a server.

You give it the root you trust with -CAfile, the intermediates with -untrusted, and the certificate to check. -show_chain prints the chain it built:

openssl verify -show_chain -CAfile root.pem -untrusted intermediate.pem cert.pem

When everything lines up, the output reads like this:

cert.pem: OK
Chain:
depth=0: CN = nas.home (untrusted)
depth=1: CN = Int (untrusted)
depth=2: CN = RootCA

“untrusted” next to depth 0 and 1 is fine: it only means those certificates came from the file you passed with -untrusted and not from the trust store. Leave out the intermediate and you get error 20 at 0 depth lookup: unable to get local issuer certificate. That’s the same error a client sees when your server sends only the leaf certificate, so it’s a quick way to prove the chain file is the problem.

For a certificate from a public CA, leave out -CAfile and OpenSSL uses the system trust store. For your own homelab CA, point -CAfile at its root.

The caveat: verify checks signatures, dates and the chain, not whether the certificate fits the name you’ll use. A perfectly valid chain for nas.home still fails in the browser on 192.168.1.10. Add -verify_hostname nas.home if you want that checked in the same run.

Further reading: openssl-verify (OpenSSL documentation)

Going deeper: Run degoog on Unraid as your own search page, compared with SearXNG and 4get

More Openssl tips openssl s_client -connect 203.0.113.10:443 -servername example.com </dev/null | openssl x509 -noout -subject openssl x509 -in cert.pem -days 365 -signkey key.pem -out cert-new.pem printf %s hello | openssl dgst -sha256 -hmac secret openssl pkcs12 -legacy -in old.pfx -nokeys echo 'aGVsbG8gd29ybGQ=' | openssl base64 -d All Openssl tips (34) All topics

Link