Nginx TLS and Certificate Trust
What HTTPS adds to HTTP
HTTPS carries HTTP inside a TLS-protected connection. TLS protects the confidentiality and integrity of traffic in transit and normally authenticates the server. It does not decide which user may view a record or whether a website is trustworthy as a business. SSL is the historical predecessor; the ssl_ names in Nginx configuration remain even when modern TLS is used.
Browser -- TLS handshake --> NginxBrowser == encrypted HTTP ==> NginxNginx -- optional separate connection --> applicationThe browser and server negotiate supported parameters and establish traffic keys during the handshake. The server demonstrates possession of its certificate private key. The client checks the server certificate before trusting application data. Modern TLS uses symmetric traffic keys for bulk encryption; the certificate does not encrypt every HTTP byte itself.
Read a certificate chain
A certificate binds a public key to an identity and is signed by an issuer. A certificate authority (CA) signs certificates. A trust anchor is a CA certificate or key accepted by the client through its configured trust policy. A leaf certificate belongs to the service; intermediates link it to a trust anchor. The private key is separate secret material. The server sends certificates, not its private key.
Trusted root CA (client trust store) signs intermediate CA signs leaf: DNS SAN catalog.testServer sends: leaf, intermediateClient supplies: trusted rootFor a server certificate file in Nginx, put the leaf first and required intermediates after it. Usually the root is already distributed independently to clients. A locally generated root used in a classroom is not automatically trusted by a browser. In this chapter the root signs the leaf directly, so the server only needs to send the leaf.
Check identity, validity and trust independently
Subject Alternative Name (SAN) identifies the intended DNS names or IP addresses. A DNS SAN for catalog.test does not match the URL https://127.0.0.1; an IP address requires an appropriate IP SAN. A valid signature alone does not establish a match for the requested host. The certificate must also be within its validity period, appropriate for server authentication, and chain to a trusted anchor under the client policy.
openssl x509 -in certs/server.pem -noout -subject -issuer -dates -ext subjectAltNameopenssl verify -purpose sslserver -verify_hostname catalog.test -CAfile certs/ca.pem certs/server.pemThe first command describes the certificate, while the second checks it against the explicit lab CA and expected name. Expect OK for a newly generated valid certificate. Neither command establishes a connection to Nginx. Checking another DNS name must fail. An incorrect system clock may cause validity errors even if a certificate was issued correctly.
SNI, termination and passthrough
Server Name Indication (SNI) is a TLS extension by which a client can indicate the server name during the handshake, before the HTTP Host field is available. Nginx can use it to choose a certificate on a shared listener. SNI is not proof of client identity and is not the same as certificate hostname verification. A TLS-terminating reverse proxy decrypts traffic at the proxy and can route by HTTP path. A passthrough proxy forwards encrypted traffic to the backend without inspecting HTTP paths. A separate TLS connection is needed if the terminating proxy must also encrypt traffic to its backend. Upstream certificate checks are a later topic.
Practice
For the fictional chain above, predict the outcome of changing only the URL name, only the trusted CA, and only the verification date. Use the offline fixture in Chapter 19 to confirm. Never bypass certificate verification to make a failed test pass.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Nginx TLS and Certificate Trust
Understand what HTTPS protects, how certificates establish server identity, and why hostname and trust checks matter.
What does a server certificate bind?
Which material should remain secret?
The trusted leaf lists catalog.test only. Which URL name matches?
When is SNI normally provided?
What can a TLS passthrough proxy not normally inspect?