---
title: "What is TLS and how HTTPS works behind the padlock | StreetHosting"
description: "Learn what TLS guarantees, how the TLS 1.3 handshake works, what certificates, chains and SNI are, and how to inspect it all with openssl s_client and curl."
url: "https://streethosting.com.br/en/guides/infrastructure/what-is-tls-how-https-works"
type: "page"
language: "en-US"
---

Infrastructure · 8 min · Intermediate

Published on Nov 13, 2026 · Updated on Nov 13, 2026

# TLS and HTTPS in practice: handshake, certificates and how to diagnose errors

The browser padlock hides a conversation of a few milliseconds between client and server. Knowing each step helps you understand why a certificate gets rejected and find the cause with two lines of commands.

By [Equipe StreetHosting](https://streethosting.com.br/en/autores#equipe-streethosting) · StreetHosting infrastructure and support team

[Certificates and HTTPS](https://streethosting.com.br/en/guides/topics/ssl)

Summarize with:

[](https://chat.openai.com/?q=Summarize%20the%20key%20points%20of%20this%20StreetHosting%20guide%3A%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Finfrastructure%2Fwhat-is-tls-how-https-works.%20Highlight%20the%20step-by-step%20instructions%2C%20the%20prerequisites%20and%20the%20most%20common%20mistakes. "ChatGPT") [](https://claude.ai/new?q=Summarize%20the%20key%20points%20of%20this%20StreetHosting%20guide%3A%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Finfrastructure%2Fwhat-is-tls-how-https-works.%20Highlight%20the%20step-by-step%20instructions%2C%20the%20prerequisites%20and%20the%20most%20common%20mistakes. "Claude") [](https://www.google.com/search?udm=50&aep=11&q=Summarize%20the%20key%20points%20of%20this%20StreetHosting%20guide%3A%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Finfrastructure%2Fwhat-is-tls-how-https-works.%20Highlight%20the%20step-by-step%20instructions%2C%20the%20prerequisites%20and%20the%20most%20common%20mistakes. "Google AI Mode") [](https://x.com/i/grok?text=Summarize%20the%20key%20points%20of%20this%20StreetHosting%20guide%3A%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Finfrastructure%2Fwhat-is-tls-how-https-works.%20Highlight%20the%20step-by-step%20instructions%2C%20the%20prerequisites%20and%20the%20most%20common%20mistakes. "Grok") [](https://www.perplexity.ai/search/new?q=Summarize%20the%20key%20points%20of%20this%20StreetHosting%20guide%3A%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Finfrastructure%2Fwhat-is-tls-how-https-works.%20Highlight%20the%20step-by-step%20instructions%2C%20the%20prerequisites%20and%20the%20most%20common%20mistakes. "Perplexity")

Share:

[](https://x.com/intent/tweet?text=What%20is%20TLS%20and%20how%20HTTPS%20works%20behind%20the%20padlock&url=https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Finfrastructure%2Fwhat-is-tls-how-https-works "Share on X") [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Finfrastructure%2Fwhat-is-tls-how-https-works "Share on Facebook") [](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Finfrastructure%2Fwhat-is-tls-how-https-works "Share on LinkedIn") [](https://wa.me/?text=What%20is%20TLS%20and%20how%20HTTPS%20works%20behind%20the%20padlock%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Finfrastructure%2Fwhat-is-tls-how-https-works "Share on WhatsApp")

For agents: Copy as Markdown [.md](https://streethosting.com.br/en/guides/infrastructure/what-is-tls-how-https-works.md)

In this guide 7 sections

* [What TLS guarantees](https://streethosting.com.br/en/guides/infrastructure/what-is-tls-how-https-works#o-que-garante)
* [The TLS 1.3 handshake](https://streethosting.com.br/en/guides/infrastructure/what-is-tls-how-https-works#handshake)
* [Certificate, chain and authority](https://streethosting.com.br/en/guides/infrastructure/what-is-tls-how-https-works#certificado)
* [SNI and several sites on one IP](https://streethosting.com.br/en/guides/infrastructure/what-is-tls-how-https-works#sni)
* [How to inspect with openssl and curl](https://streethosting.com.br/en/guides/infrastructure/what-is-tls-how-https-works#inspecionar)
* [Common errors](https://streethosting.com.br/en/guides/infrastructure/what-is-tls-how-https-works#erros)
* [Your own web server](https://streethosting.com.br/en/guides/infrastructure/what-is-tls-how-https-works#onde-rodar)

Quick answer

**TLS**is the protocol that protects an HTTPS connection. It guarantees three things: confidentiality, because nobody along the way reads the data, integrity, because nobody changes the content without being noticed, and authentication, because the server proves it owns the site's name through a certificate signed by a trusted authority. To see all of it in action, run `openssl s_client -connect host:443 -servername host` or `curl -vI https://host`.

## What TLS guarantees[](https://streethosting.com.br/en/guides/infrastructure/what-is-tls-how-https-works#o-que-garante)

Plain HTTP travels in the open: anyone along the path between you and the server, such as a public wireless network or an internet provider, can read and even modify the content. TLS fixes this with three guarantees.

* **Confidentiality:** the data is encrypted with a key that only the two ends know. Whoever captures the traffic sees meaningless bytes.
* **Integrity:** every block carries a check. If someone changes a single bit along the way, the connection detects it and closes.
* **Authentication:** the server presents a certificate proving it controls that domain name. Without it, encryption would be useless, because you could be talking to an impostor over a very well encrypted channel.

What TLS does not do matters too. The padlock says the channel is secure and that the name matches the certificate, not that the site is honest. And TLS protects the trip: if the server is broken into, the data is exposed inside it. Attacks on the application are a different topic, covered in [what a WAF is](https://streethosting.com.br/en/guides/infrastructure/what-is-a-waf).

## The TLS 1.3 handshake[](https://streethosting.com.br/en/guides/infrastructure/what-is-tls-how-https-works#handshake)

Before exchanging any page data, client and server perform the handshake: a short conversation to agree on the rules and create a secret key. In TLS 1.3, it takes one round trip.

1. **ClientHello:** the client introduces itself. It says which versions and ciphers it accepts, which site name it wants (the SNI) and sends its half of a key exchange, usually done with elliptic curves such as X25519.
2. **ServerHello:** the server picks the cipher and answers with its half of the key exchange. At this point both sides already compute, each on its own, the same secret key, without it ever having traveled over the network.
3. **Certificate and proof:** from here on everything is already encrypted. The server sends the certificate and a signature made with its private key, which proves it is the owner of that certificate.
4. **Finished:** each side confirms that the whole handshake arrived intact. The client checks the certificate and, if all is well, the page starts loading, already encrypted.

The halves of the key exchange are temporary and discarded after the connection, which is why TLS 1.3 has forward secrecy: even if the server's private key leaks tomorrow, connections recorded yesterday stay unreadable. By comparison, TLS 1.2 needed two round trips and still accepted old ciphers. Version 1.3 removed the weak ones and shortened the wait, which helps most when the [latency to the server](https://streethosting.com.br/en/guides/infrastructure/what-is-latency-and-ping) is high, since each round trip costs the ping time.

## Certificate, chain and authority[](https://streethosting.com.br/en/guides/infrastructure/what-is-tls-how-https-works#certificado)

A certificate is a digital document that ties a domain name to a public key, signed by a certificate authority, the CA. It carries the name or names it covers, the validity period, the public key and the signature of whoever issued it.

The browser does not know your server, but it does know a small group of root authorities, which come installed in the system or in the browser itself. Trust reaches your certificate through a chain:

| Link                     | Who it is                         | Who signs it     | Where it lives                   |
| ------------------------ | --------------------------------- | ---------------- | -------------------------------- |
| Root certificate         | The authority itself              | Itself           | Installed on the client's system |
| Intermediate certificate | An issuer delegated by the root   | The root         | Sent by the server               |
| Site certificate         | Your domain, also called the leaf | The intermediate | Sent by the server               |

The server has to send the site certificate and the intermediates. The root does not need to be sent, because the client already has it. That is why the right file to configure in Nginx is `fullchain.pem`, which bundles the certificate and the intermediates, and not the certificate alone. Validity is checked on every connection, and the certificate also has to cover the name being accessed. The guide on [an SSL certificate with Let's Encrypt and Nginx on a VPS](https://streethosting.com.br/en/guides/vps/lets-encrypt-ssl-certificate-vps) shows how to issue and renew one for free, already with the right file.

## SNI and several sites on one IP[](https://streethosting.com.br/en/guides/infrastructure/what-is-tls-how-https-works#sni)

A single server, with a single IP, often hosts many domains. The problem is that the handshake happens before the browser says which site it wants, which is done later, inside HTTP. How would the server know which certificate to present?

The answer is SNI (Server Name Indication): a ClientHello field where the client states the name it wants. The server reads the name and picks the right certificate, just as Nginx does with each domain's `server` block. When SNI is missing, the server hands over the default certificate, which is almost never the requested site's, and the browser complains about a wrong name. SNI travels unencrypted in regular TLS 1.3, so whoever watches the network sees the site name, even without seeing the content. An extension that encrypts this field exists, ECH, but it needs support on both ends.

That is why, when testing a server that hosts several sites, you always need to state the name. It is what the openssl `-servername` option does, in the next section. This scenario shows up in [Nginx as a reverse proxy on a VPS](https://streethosting.com.br/en/guides/vps/nginx-reverse-proxy-vps), where each domain has its own certificate.

## How to inspect with openssl and curl[](https://streethosting.com.br/en/guides/infrastructure/what-is-tls-how-https-works#inspecionar)

`openssl s_client` performs the handshake and shows everything that happened. Replace `exemplo.com.br` with your domain:

`# full connection, with the chain the server sends openssl s_client -connect exemplo.com.br:443 -servername exemplo.com.br -showcerts </dev/null # only the main details of the site certificate openssl s_client -connect exemplo.com.br:443 -servername exemplo.com.br </dev/null 2>/dev/null \ | openssl x509 -noout -subject -issuer -dates -ext subjectAltName`

The `</dev/null` closes the input so the command ends by itself instead of waiting for you to type. In the report, three points deserve attention:

* **Certificate chain:**lists the certificates sent. It should have the site's and the intermediates. If only one shows up, the chain is incomplete.
* **Verify return code:** at the end of the output. It is `0 (ok)` when verification passed. Other codes explain the problem, such as 20 or 21 for an incomplete chain and 10 for an expired certificate.
* **Protocol and Cipher:** the negotiated version, such as `TLSv1.3`, and the chosen cipher.

curl, in turn, shows the same negotiation in a shorter form, along with the HTTP response:

`curl -vI https://exemplo.com.br`

On the lines that start with an asterisk, curl reports the TLS version, the cipher, the issuer, the validity dates and the verification result, and then come the response headers. If the certificate is rejected, curl ends with a clear error message, and the `-k` option makes it ignore the error just so you can confirm the rest works. Use it only to diagnose, never in a script that handles real data.

To test a server before DNS points to it, use `curl -vI --resolve exemplo.com.br:443:IP_DA_VPS https://exemplo.com.br`. curl connects to the IP you gave, but sends the right name in the SNI and in the Host header. Pointing the domain is covered in the guide on [how to point a domain to your VPS](https://streethosting.com.br/en/guides/vps/point-domain-to-vps).

## Common errors[](https://streethosting.com.br/en/guides/infrastructure/what-is-tls-how-https-works#erros)

| Symptom                                                           | Likely cause                                                        | How to confirm                                            | Fix                                                         |
| ----------------------------------------------------------------- | ------------------------------------------------------------------- | --------------------------------------------------------- | ----------------------------------------------------------- |
| unable to get local issuer certificate, or verify error 20 and 21 | Incomplete chain: the server does not send the intermediate         | Certificate chain shows a single certificate              | Configure fullchain.pem instead of the certificate alone    |
| certificate has expired, or verify error 10                       | The certificate passed its validity, usually because renewal failed | The notAfter line is in the past                          | Renew, and check the renewal timer or cron job              |
| no alternative certificate subject name matches                   | The name being accessed is not in the certificate                   | Compare the domain with the subjectAltName list           | Issue a certificate that covers the name, including www     |
| Another site's certificate                                        | Missing SNI, or a server block without the right name               | Repeat the test with and without -servername              | Create the domain's block in Nginx with its own certificate |
| Certificate is not yet valid                                      | Client or server clock set to the wrong date                        | Compare the output of the date command with the real time | Fix the clock and turn on automatic synchronization         |

The clock error is very misleading because it shows up as a certificate problem, but the cause is the device's date. On a server, time synchronization is the fix, and the guide on [NTP and the correct time on a Linux server](https://streethosting.com.br/en/guides/infrastructure/configure-ntp-linux-server) shows how.

An incomplete chain is treacherous because your browser may open the site normally: it completes the chain by itself, with intermediates it has seen before or downloads on the spot. curl, phone apps, integrations and other servers do not do that and fail. Always test with openssl or curl as well, and not only in the browser.

## Your own web server[](https://streethosting.com.br/en/guides/infrastructure/what-is-tls-how-https-works#onde-rodar)

Setting up TLS properly means installing the certificate, pointing Nginx at the right file and taking care of renewal, all with access to the server. On a [StreetHosting VPS](https://streethosting.com.br/en/vps) you have root access, so you install Nginx and certbot, and use this guide's openssl and curl directly on the server. All of them are in São Paulo, with a dedicated IPv4 and AntiDDoS included. The Xeon VPS starts at R$ 26.00 per month, with 2 vCPU, 2 GB of RAM and 20 GB of NVMe, enough for a site with HTTPS.

In this guide

* [What TLS guarantees](https://streethosting.com.br/en/guides/infrastructure/what-is-tls-how-https-works#o-que-garante)
* [The TLS 1.3 handshake](https://streethosting.com.br/en/guides/infrastructure/what-is-tls-how-https-works#handshake)
* [Certificate, chain and authority](https://streethosting.com.br/en/guides/infrastructure/what-is-tls-how-https-works#certificado)
* [SNI and several sites on one IP](https://streethosting.com.br/en/guides/infrastructure/what-is-tls-how-https-works#sni)
* [How to inspect with openssl and curl](https://streethosting.com.br/en/guides/infrastructure/what-is-tls-how-https-works#inspecionar)
* [Common errors](https://streethosting.com.br/en/guides/infrastructure/what-is-tls-how-https-works#erros)
* [Your own web server](https://streethosting.com.br/en/guides/infrastructure/what-is-tls-how-https-works#onde-rodar)

## Frequently asked questions

What is the difference between HTTPS, TLS and SSL?

HTTPS is HTTP running inside a TLS connection. TLS is the protocol that encrypts and authenticates that connection. SSL is the name of the old protocol that TLS replaced, and today every SSL version is considered insecure. When someone says SSL certificate, they almost always mean a certificate for TLS.

What does the browser padlock guarantee?

It guarantees the connection is encrypted and that the server proved it controls the site's name. It does not guarantee the site is honest: a scam site can also have a valid certificate. The padlock speaks about the channel, not about the good faith of whoever is on the other end.

What is SNI for?

SNI is the field where the client states the name of the site it wants, right at the start of the handshake. With it, a server with a single IP picks the right certificate for each domain. Without SNI, the server could only present one certificate per IP.

Why does the browser show a certificate error if the certificate is valid?

The most common causes are an incomplete chain, where the server does not send the intermediate certificate, a site name that is not listed in the certificate and a device clock set to the wrong date. Running openssl s\_client shows which of these it is.

Is TLS 1.3 faster than TLS 1.2?

Generally yes. TLS 1.3 completes the handshake in one round trip, while 1.2 uses two, and it resumes old sessions with even less waiting. It also removed weak ciphers, which makes the default setup safer.

Next step

See VPS plans

Root VPS in Brazil with NVMe and Anti-DDoS.

[See VPS plans](https://streethosting.com.br/en/vps)

## Related guides

[VPS Beginner SSL certificate on a VPS with Let's Encrypt and Nginx A site without the padlock loses trust and rankings. This guide shows how to issue, renew and audit a free SSL certificate on your VPS with Nginx and Certbot. 4 min Read guide](https://streethosting.com.br/en/guides/vps/lets-encrypt-ssl-certificate-vps) [VPS Intermediate How to set up Nginx as a reverse proxy on a VPS Your app runs on an internal port and you want to serve it on a domain with HTTPS. Nginx as a reverse proxy solves that and also brings several apps together in one place. 3 min Read guide](https://streethosting.com.br/en/guides/vps/nginx-reverse-proxy-vps) [Infrastructure Intermediate How to configure NTP and the correct time on a Linux server A server with the wrong clock causes confusing logs, SSL certificate failures and authentication problems. Here is how to set up NTP with chrony or systemd-timesyncd and pick the right time zone. 3 min Read guide](https://streethosting.com.br/en/guides/infrastructure/configure-ntp-linux-server)

[← Back to the Guide Center](https://streethosting.com.br/en/guides)
