TLS encrypts a connection and, before the first byte of http,
lets the client check that the server is who it claims to be. For that the
server presents a certificate: a public key, site
names and a validity period, vouched for by the signature of a
certificate authority. The matching
private key stays on the server only.
$ openssl x509 -in site.pem -noout -subject -issuer -dates \
-ext subjectAltName
subject=CN = secure.lab.test
issuer=CN = Lab Intermediate CA
notBefore=Oct 20 10:04:50 2026 GMT
notAfter=Nov 19 10:04:50 2026 GMT
X509v3 Subject Alternative Name:
DNS:secure.lab.test
subject is who it was issued to, issuer who signed it,
notBefore/notAfter the validity period, SAN the
names the certificate is valid for.
The client's three checks
| Check |
What it compares |
curl error |
| trust |
the signature chain reaches a CA in the store |
unable to get local issuer certificate |
| name |
the name from the URL is in SAN |
no alternative certificate subject name matches |
| date |
now is between notBefore and notAfter |
certificate has expired |
If any fails, curl exits with code 60 and a browser shows an error page.
curl -k turns all three off: the connection is encrypted, but nobody knows
with whom.
The chain and trust
A site certificate is usually signed not by a root but by an
intermediate CA, which the root signed. The root is
signed by itself (subject = issuer) and is
trusted because it sits in the client's trust store. On
Ubuntu that is /etc/ssl/certs; update-ca-certificates adds your own root,
and curl --cacert ca.pem does it for one request.
The client knows only roots. The server sends the intermediate along with the
site certificate — that is the chain. If the server
sends only the site certificate, the client cannot reach the root and reports
unable to get local issuer certificate, even though it has the root.
Key, request, certificate
PEM files are text between -----BEGIN …----- and -----END …----- lines,
base64 inside. The first line tells what the file holds:
| First line |
What it is |
-----BEGIN PRIVATE KEY----- |
a private key |
-----BEGIN CERTIFICATE REQUEST----- |
a CSR |
-----BEGIN CERTIFICATE----- |
a certificate |
A certificate is issued from a signing request (CSR): it holds the
public key and the requested names. The CA signs the request and returns a
certificate. A new request on the old key gives a new certificate without
changing the key.