Flags, examples, and common workflows.
| Flag | Default | Description |
|---|---|---|
| -port | 443 | TLS port to connect to. Can also be passed as a positional argument after the hostname. |
| -o | <hostname>-ca.pem | Output file path. Pass - to write to stdout instead of a file. |
| -all | off | Save the full chain including the leaf certificate. By default only CA certs are saved. |
| -fetch-root | off | Chase the AIA (Authority Information Access) extension to download the root CA from the issuer's URL. |
| -insecure | off | Skip TLS certificate verification. Use this for self-signed or private-CA servers. |
| -timeout | 10 | Connection timeout in seconds. |
| -version | โ | Print version and exit. |
The simplest invocation. Connects to port 443, walks the chain, and saves the CA cert to hostname-ca.pem.
$ tls-ca-fetch github.com โ Connecting to github.com:443 โฆ Chain received: 2 certificate(s) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ [0] leaf CN=github.com IsCA=false Issuer : DigiCert TLS Hybrid ECC SHA384 2020 CA1 Expires: 2026-03-26 [1] intermediate CA CN=DigiCert TLS Hybrid ECC SHA384 IsCA=true Issuer : DigiCert Global Root CA Expires: 2031-04-13 AIA : http://cacerts.digicert.com/DigiCertGlobalRootCA.crt โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ Saved 1 CA certificate(s) โ github.com-ca.pem Verified: 1 PEM block(s) readable in output file
Use -o - to emit PEM on stdout and pipe it directly into OpenSSL, curl, or a config generator.
$ tls-ca-fetch -o - internal.corp.example \ | openssl x509 -noout -subject -issuer -dates
Pass the port as a flag or as a second positional argument.
# flag form $ tls-ca-fetch -port 8443 internal.example.com # positional arg form $ tls-ca-fetch smtp.example.com 587
By default the leaf is omitted. Use -all to save every cert in the chain.
$ tls-ca-fetch -all -o chain.pem api.example.com
-fetch-root follows the AIA URL in the topmost cert and appends the root CA to the output.
$ tls-ca-fetch -fetch-root -o full-chain.pem smtp.example.com 587
Use -insecure when the server cert isn't publicly trusted โ Vault, internal services, dev environments.
$ tls-ca-fetch -insecure -o my-internal-ca.pem vault.internal
Fetch the cert then drop it into the system trust store in one go.
$ tls-ca-fetch corp-proxy.internal $ sudo cp corp-proxy.internal-ca.pem \ /usr/local/share/ca-certificates/corp-proxy.crt $ sudo update-ca-certificates Updating certificates in /etc/ssl/certs... 1 added, 0 removed; done.
The chain summary labels each cert by its role in the PKI hierarchy.
| Role | Meaning | Saved by default? |
|---|---|---|
| leaf | End-entity cert presented by the server. Identifies the hostname. IsCA=false. |
No (use -all) |
| intermediate CA | Signed by the root, signs the leaf. The trust bridge. IsCA=true. |
Yes |
| root CA | Self-signed trust anchor. Usually not sent by servers โ use -fetch-root to retrieve it via AIA. |
Only via -fetch-root |