A Deep Dive into HTTPS: How SSL/TLS, Hybrid Encryption, and Certificates Secure Web Traffic
This article explains HTTPS from the ground up, covering one‑way and two‑way authentication, the SSL/TLS handshake, asymmetric and symmetric encryption, digital signatures and hashes, key exchange, and the role of digital certificates and revocation in ensuring confidentiality, integrity, and authenticity.
Review of HTTP Communication
The article begins by recalling the basic HTTP request/response flow.
1️⃣ One‑Way Authentication
In one‑way authentication the client verifies the server’s identity while the server does not verify the client. The handshake proceeds as follows:
Client initiates HTTPS request: The user enters an HTTPS URL; the client connects to the server’s port 443.
Server responds and sends its certificate: The server returns its SSL/TLS digital certificate containing the public key, CA information, and signature.
Client validates the server certificate: The client checks the issuing CA, expiration date, and signature. Failure triggers a warning or connection abort.
Key exchange and generation: After successful validation, the client creates a random pre‑master secret, encrypts it with the server’s public key, and sends it to the server. Both sides derive a session key from the pre‑master secret and other parameters.
Establish secure connection: The client and server use the negotiated session key to encrypt all subsequent traffic.
Data transmission: All data is encrypted before transmission and decrypted by the receiver using the session key.
Connection closure: After data transfer, the connection is closed; a new handshake is required for future communication.
Through these steps HTTPS guarantees confidentiality, integrity, and authenticity.
2️⃣ Two‑Way Authentication
Two‑way (mutual) authentication adds a step where the server also verifies the client’s certificate, typically used in high‑security scenarios such as banking.
The client sends its own digital certificate along with the HTTPS request.
The server validates the client certificate; failure may cause the server to reject the connection.
Upon successful validation, the server and client continue with key exchange and secure connection establishment.
Mutual authentication provides stronger security but increases configuration complexity and cost.
SSL/TLS Protocol Details
HTTPS adds an SSL/TLS layer on top of HTTP to provide encryption and authentication. The handshake is the core of SSL/TLS:
Client sends a list of supported cipher suites.
Server selects a cipher suite and returns its certificate.
Client validates the certificate, generates a pre‑master secret, encrypts it with the server’s public key, and sends it.
Both parties derive a session key from the pre‑master secret and other parameters.
After the handshake, data encryption uses the session key, and data integrity is protected by a Message Authentication Code (MAC).
Encryption Techniques
HTTPS employs both asymmetric and symmetric encryption:
1. Asymmetric Encryption
Used for key exchange and digital certificates. The server’s public key encrypts a randomly generated symmetric key (the session key), which only the server can decrypt with its private key.
2. Symmetric Encryption
Used for the actual payload. The session key encrypts and decrypts the data, offering high performance for large volumes of traffic.
Digital Signatures and Hashes
Digital signatures and hash functions ensure data integrity and authenticity:
Signature generation: The sender (usually the server) encrypts a hash of the data with its private key, producing a digital signature.
Signature verification: The receiver decrypts the signature with the sender’s public key to obtain hash A, computes hash B over the received data, and compares A and B. A match confirms that the data has not been altered.
Hash properties: Hash functions are one‑way; any change in the input yields a drastically different hash, enabling integrity checks.
HTTPS typically uses both together: the server signs the hash of the data, and the client verifies the signature and recomputes the hash.
Key Exchange and Data Encryption Steps
Key exchange: The server sends its public key (in the certificate). The client validates the certificate, generates a random symmetric session key, encrypts it with the server’s public key, and sends it. The server decrypts to obtain the session key.
Data encryption: Both parties use the session key to encrypt and decrypt the actual payload, ensuring confidentiality even if the traffic is intercepted.
The hash is used solely for integrity verification, not for encrypting the payload.
Digital Certificates and Authentication
Certificates, issued by trusted Certificate Authorities (CAs), bind a public key to an entity’s identity.
Purpose: Verify the server’s identity; the client checks the certificate against trusted CA roots.
Certificate chain: Validation may involve traversing from the server certificate up to the root CA.
Revocation: If a private key is compromised, the CA can revoke the certificate. Clients check revocation via CRL or OCSP.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Programmer1970
Formerly called 'Code to 35'. Add our main WeChat ID to access a wealth of shared resources (algorithms, interview prep, tech stacks: Java, Python, Go, big data). We mainly share serious development techniques, focusing on output-driven input. Occasionally we post life snippets and gossip. Our aim is to attract precise traffic and test advertising opportunities.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
