TLS, HTTPS, and Secure Communication

By Oleksandr Andrushchenko — Published on
0 Likes
0 Dislikes

Network traffic often crosses infrastructure that is not controlled by the application: Wi-Fi networks, ISPs, corporate proxies, cloud networks, load balancers, and internet routing infrastructure. Without transport security, attackers on the network path may be able to read traffic, modify requests, inject responses, or impersonate services.

TLS (Transport Layer Security) protects communication between network endpoints by providing encryption, integrity, and authentication. HTTPS is HTTP transported over TLS, allowing APIs and web applications to exchange sensitive data without exposing plaintext traffic to intermediate networks.

Production TLS design extends beyond enabling HTTPS on a public endpoint. Certificate validation, TLS termination, service-to-service encryption, connection reuse, certificate rotation, and failure handling all affect security, latency, availability, and operational complexity.

Table of Contents

What TLS Protects

TLS provides three fundamental security properties: confidentiality, integrity, and authentication.

Property Purpose Example Threat
Confidentiality Encrypt traffic so intermediaries cannot read application data Network observer reading passwords or API tokens
Integrity Detect unauthorized modification of transmitted data Attacker modifying an API response in transit
Authentication Verify the identity of the server and optionally the client Attacker impersonating api.example.com

Without TLS, a simplified HTTP request travels as readable application data:

Client
  |
  | plaintext
  |
  | POST /login
  | username=alice
  | password=secret
  v
Server

With TLS, HTTP data is protected inside an encrypted connection:

Client
  |
  | TLS encrypted traffic
  | ************************
  | ************************
  v
Server

An observer can still learn some network-level metadata, such as source and destination addresses, connection timing, and approximate traffic volume. TLS protects application data in transit; it does not make network communication invisible.

TLS
TLS

TLS also does not determine whether an authenticated user is allowed to perform an application operation. Authentication and authorization remain application-level security concerns.

For broader API security architecture, see Designing Secure API Architectures.

The TLS Handshake

Before encrypted application traffic can flow, the client and server establish cryptographic parameters through a TLS handshake.

A simplified TLS 1.3 handshake looks like:

Client                                  Server
  |                                       |
  | ClientHello                           |
  | supported algorithms + key share      |
  |-------------------------------------->|
  |                                       |
  |          ServerHello + key share      |
  |          Certificate                  |
  |          CertificateVerify            |
  |          Finished                     |
  |<--------------------------------------|
  |                                       |
  | Finished                              |
  |-------------------------------------->|
  |                                       |
  |====== Encrypted Application Data =====|

The handshake performs several jobs simultaneously. The peers negotiate cryptographic parameters, the server proves its identity using a certificate, and both sides derive symmetric keys used to protect application traffic.

Modern TLS uses asymmetric cryptography primarily during authentication and key establishment. Once the connection is established, efficient symmetric encryption protects the bulk application data.

Certificate Validation

Receiving a certificate is not enough. The client must determine whether that certificate should be trusted for the requested service.

A simplified certificate trust chain looks like:

Trusted Root CA
      |
      v
Intermediate CA
      |
      v
api.example.com Certificate

The client typically verifies several properties:

  • the certificate is valid for the requested hostname
  • the certificate is within its validity period
  • the certificate chains to a trusted certificate authority
  • the signatures in the certificate chain are valid
  • the certificate satisfies relevant usage constraints

Hostname validation is particularly important.

If the application requests:

https://api.example.com

a valid certificate for an unrelated hostname should not be accepted simply because it was issued by a trusted certificate authority.

Disabling certificate verification removes one of TLS's core security guarantees and makes man-in-the-middle attacks possible.

Session Key Establishment

TLS does not encrypt every application byte using expensive public-key operations. The handshake establishes shared cryptographic secrets from which efficient symmetric session keys are derived.

The conceptual flow is:

Authenticated Handshake
        |
        v
Shared Secret
        |
        v
Derived Session Keys
        |
        v
Symmetric Encryption
        |
        v
HTTP / API Traffic

Modern ephemeral key exchange also provides forward secrecy. Compromise of a server's long-term private key should not automatically allow previously recorded sessions to be decrypted.

TLS 1.3 simplifies the handshake compared with older protocol generations and reduces the number of round trips required before protected application communication can begin.

HTTPS

HTTPS is HTTP over TLS. HTTP still defines methods, headers, status codes, URLs, and message semantics. TLS protects the connection carrying those HTTP messages.

HTTPS
HTTPS

HTTP over TLS

A simplified HTTPS request path is:

DNS Resolution
      |
      v
Network Connection
      |
      v
TLS Handshake
      |
      v
Encrypted HTTP Request
      |
      v
Encrypted HTTP Response

For HTTP/1.1 and HTTP/2, HTTPS commonly operates over TLS on top of TCP:

HTTP
  |
TLS
  |
TCP
  |
IP

HTTP/3 uses QUIC, which integrates TLS 1.3 into the transport protocol:

HTTP/3
   |
QUIC + TLS 1.3
   |
UDP
   |
IP

For protocol-level differences, see HTTP/1.1 vs HTTP/2 vs HTTP/3.

HTTPS protects request and response contents while they travel between the two TLS endpoints. The exact location of those endpoints therefore matters.

Connection Reuse

A new TLS handshake adds network and cryptographic work before application data can flow. Reusing established connections avoids repeatedly paying that cost.

Without reuse:

Request 1 -> TCP/QUIC + TLS -> HTTP
Request 2 -> TCP/QUIC + TLS -> HTTP
Request 3 -> TCP/QUIC + TLS -> HTTP


With reuse:

Connection -> TLS Handshake
                 |
                 +-> Request 1
                 +-> Request 2
                 +-> Request 3

Connection reuse is therefore important for both performance and capacity.

HTTP/2 and HTTP/3 can multiplex multiple streams over a connection, reducing the need for large numbers of parallel connections.

Connection lifetime still requires balance. Connections that live too briefly create repeated handshake overhead. Extremely long-lived connections can complicate deployments, certificate changes, load redistribution, and resource management.

TLS Termination

TLS termination is the point where encrypted traffic is decrypted.

In small applications, TLS may terminate directly on the application server. Larger architectures commonly terminate TLS at an edge proxy, CDN, ingress layer, API gateway, or load balancer.

Edge Termination

A common architecture terminates public TLS at a reverse proxy or Layer 7 load balancer:

Client
  |
  | HTTPS
  v
Load Balancer / Reverse Proxy
  |
  | HTTP or HTTPS
  v
Application

This centralizes certificate management and removes public TLS processing from application instances.

Advantages:

  • centralized certificate deployment and rotation
  • simpler application configuration
  • consistent TLS policies
  • application instances remain hidden behind controlled infrastructure
  • edge infrastructure can reuse upstream connections

Disadvantages:

  • traffic is plaintext after termination if backend encryption is not enabled
  • the termination layer becomes security-sensitive infrastructure
  • applications must correctly interpret trusted forwarding information

When to Use: edge termination is common for public websites and APIs where a managed load balancer, ingress controller, gateway, or reverse proxy owns the external HTTPS endpoint.

End-to-End Encryption

TLS can also be used between the proxy and backend:

Client
  |
  | TLS Connection A
  v
Load Balancer / Proxy
  |
  | TLS Connection B
  v
Application

This is sometimes described as TLS re-encryption. The public connection terminates at the proxy, and a separate encrypted connection protects the next hop.

It is important to recognize that these are two independent TLS sessions:

Client ===== encrypted =====> Proxy
                               |
                               | decrypt
                               | inspect / route
                               | encrypt
                               v
Proxy  ===== encrypted =====> Backend

The proxy can see plaintext because it is a TLS endpoint. Encryption on every network hop therefore does not mean that intermediaries participating in TLS termination cannot inspect the request.

Backend TLS can protect traffic across shared networks, reduce trust in network isolation, and support stronger service identity models.

The trade-off is additional certificate management, handshake overhead, debugging complexity, and operational dependencies.

Service-to-Service Security

Internal traffic should not automatically be considered trusted merely because it travels through a private network.

Modern systems often contain many workloads, shared clusters, automation identities, and multiple network boundaries. Encrypting internal communication limits the value of passive network access and creates opportunities for stronger service authentication.

Mutual TLS

Normal public HTTPS usually authenticates the server to the client.

Client ----------------> Server
       verifies server
       certificate

Mutual TLS (mTLS) authenticates both endpoints using certificates.

Service A                         Service B
   |                                 |
   | Client certificate              |
   |-------------------------------->|
   |                                 |
   |              Server certificate |
   |<--------------------------------|
   |                                 |
   | Both identities verified        |
   |                                 |
   |====== Encrypted Connection =====|

This is useful when services need strong machine identity rather than relying only on network location.

Advantages:

  • both sides authenticate cryptographically
  • service identity does not depend entirely on IP addresses
  • traffic remains encrypted between services
  • compromised network access alone is insufficient to impersonate a service

Disadvantages:

  • every participating workload needs certificate lifecycle management
  • certificate issuance and rotation become critical infrastructure
  • expired or invalid certificates can cause widespread connectivity failures
  • debugging identity and trust-chain failures becomes more complex

When to Use: mTLS is valuable for sensitive internal APIs, zero-trust architectures, service meshes, cross-environment communication, and systems requiring strong workload identity.

Identity and Authorization

mTLS answers an important question:

"Which service established this connection?"

It does not automatically answer:

"What is this service allowed to do?"

Authentication and authorization remain separate concerns.

For example, a certificate may prove that the caller is the reporting-service, but policy must still determine whether that service may call:

POST /payments/refund

A production security model can therefore combine:

TLS
 |
 +-> Encryption
 |
 +-> Peer Authentication
       |
       v
Service Identity
       |
       v
Authorization Policy
       |
       v
Allowed Operation

TLS should be treated as one layer of the security architecture rather than a replacement for API authentication and authorization.

Certificate Management

Certificates expire. Private keys must be protected. Trust chains change. New hosts appear and old hosts disappear. As a result, certificate lifecycle management is an operational reliability problem as well as a security problem.

A simplified lifecycle is:

Generate / Request
       |
       v
Validate Identity
       |
       v
Issue Certificate
       |
       v
Deploy
       |
       v
Monitor Expiration
       |
       v
Renew
       |
       v
Rotate

Manual certificate management does not scale well because a forgotten certificate can turn into a production outage at expiration time.

Automation should handle issuance and renewal where possible, while monitoring verifies that automation is actually working.

Important certificate metrics and alerts include:

  • days until certificate expiration
  • renewal failures
  • certificate deployment failures
  • TLS handshake failures
  • hostname-validation failures
  • unknown or untrusted certificate authorities

Rotation should happen well before expiration rather than at the last possible moment.

Private keys require stricter protection than certificates. Certificates are intentionally distributed to peers, while private keys must remain accessible only to the components that require them.

For broader credential lifecycle principles, see Secrets Management in Cloud Applications.

Production Design Example

Consider a logistics platform exposing public APIs to mobile applications, browser clients, and external carrier integrations. Internally, several services communicate with each other to retrieve shipments, calculate rates, purchase labels, and track deliveries.

The security design must protect both internet-facing traffic and internal service communication.

Architecture

                    External Clients
                          |
                          | HTTPS
                          v
                   DNS / Public Edge
                          |
                          | TLS
                          v
                 Layer 7 Load Balancer
                          |
                          | TLS
                          v
                      API Gateway
                    /      |       \
                   /       |        \
                  v        v         v
            Shipment    Rating    Tracking
             Service    Service    Service
                 \         |          /
                  \        |         /
                   +-------+--------+
                           |
                        mTLS
                           |
                           v
                    Carrier Gateway
                           |
                           | HTTPS
                           v
                    Carrier APIs

The public edge owns the external certificate for api.example.com. Traffic from clients to the edge is encrypted using HTTPS.

Internal hops can also use TLS, while sensitive service-to-service paths can use mTLS when both encryption and workload authentication are required.

Request Flow

Suppose a client requests tracking information:

GET https://api.example.com/shipments/SH123/tracking

The client first resolves the hostname and connects to the public endpoint. DNS and traffic-routing behavior are covered in DNS, Load Balancers, and Reverse Proxies.

The public TLS handshake validates the server certificate:

Client
  |
  | ClientHello
  v
Public Edge
  |
  | Certificate for api.example.com
  | TLS handshake completes
  v
Encrypted HTTPS connection

The edge decrypts the request and performs application routing. If backend encryption is enabled, it creates or reuses another TLS connection toward the API gateway.

The Tracking Service may need data from a carrier integration service. An internal mTLS connection can authenticate both workloads:

Tracking Service
      |
      | mTLS
      | identity: tracking-service
      v
Carrier Gateway
      |
      | authorization policy
      v
Allowed carrier operation

The Carrier Gateway then establishes a separate HTTPS connection to the external carrier API.

The complete request therefore crosses several independent TLS boundaries:

Client
  ||
  || TLS #1
  \/
Public Edge
  ||
  || TLS #2
  \/
API Gateway
  ||
  || TLS #3
  \/
Internal Service
  ||
  || TLS #4
  \/
External Provider

Each boundary has its own certificates, connection pools, timeouts, trust configuration, and failure modes.

Failure and Recovery Flow

TLS introduces failure modes that can make otherwise healthy services unreachable.

Consider an expired internal certificate:

Tracking Service
      |
      | attempts TLS connection
      v
Carrier Gateway
      |
      | certificate expired
      X
Handshake fails
      |
      v
Carrier requests unavailable

The network path is healthy. Both processes are running. The failure exists entirely in the trust layer.

This distinction matters during incident response because generic connection errors can otherwise be mistaken for network outages.

Another failure can occur during certificate rotation:

Old CA trusted
      |
Certificate rotation
      |
      v
New certificate signed by New CA
      |
      v
Some clients do not trust New CA
      |
      v
Partial connectivity failure

Safe rotation may require a transition period where both old and new trust chains are accepted before the old trust is removed.

TLS failures should also interact carefully with retry logic. Repeatedly retrying a deterministic certificate-validation failure does not repair the problem and can generate unnecessary load.

Production monitoring should include:

  • TLS handshake success and failure rates
  • handshake latency
  • certificate expiration time
  • certificate renewal failures
  • hostname-validation failures
  • certificate-chain validation failures
  • protocol version distribution
  • cipher negotiation failures
  • connection establishment latency
  • connection reuse rate
  • active TLS connections
  • connection resets
  • mTLS authentication failures by service identity
  • authorization failures after successful authentication

Monitoring should distinguish network connection failures, TLS handshake failures, and application failures. These represent different layers and require different recovery actions.

Common Mistakes

TLS configuration often appears simple until certificates, proxies, internal services, and automated rotation introduce multiple independent trust boundaries.

Mistake Production Impact Better Approach
Disabling certificate verification Connections become vulnerable to server impersonation and man-in-the-middle attacks. Validate certificates and fix the underlying trust configuration.
Using HTTPS only on public traffic Sensitive internal traffic may cross networks in plaintext. Encrypt internal hops according to the threat model.
Assuming TLS provides authorization Authenticated services may access operations they should not use. Apply authorization after identity verification.
Managing certificates manually Expired certificates create avoidable outages. Automate issuance, renewal, deployment, and monitoring.
Alerting only after certificate expiration Operators have no recovery window before an outage. Alert well before expiration.
Rotating trust roots in one step Clients that lack the new trust chain lose connectivity. Use overlapping trust during migrations.
Opening a new TLS connection for every request Handshake latency and CPU overhead increase. Reuse connections and configure appropriate pools.
Ignoring TLS termination boundaries Traffic believed to be encrypted may travel plaintext on internal hops. Document encryption state for every network segment.
Sharing private keys unnecessarily Compromise of one system increases the security blast radius. Limit private-key access to required workloads.
Treating TLS errors as generic network failures Certificate and trust problems take longer to diagnose. Expose TLS-specific metrics, logs, and alerts.

Production Checklist

  • Require HTTPS for public applications and APIs. Avoid sending credentials or application data over plaintext internet connections.
  • Use modern TLS configurations. Disable obsolete protocol versions and weak cryptographic configurations.
  • Validate server certificates. Never disable certificate validation as a permanent workaround.
  • Validate hostnames. Confirm certificates represent the service being contacted.
  • Document TLS termination points. Know exactly where encrypted traffic becomes plaintext.
  • Evaluate every internal hop. Apply backend TLS where network trust alone is insufficient.
  • Use mTLS where workload identity is required. Authenticate both sides of sensitive service-to-service communication.
  • Separate authentication from authorization. A valid certificate should not automatically grant unrestricted access.
  • Automate certificate issuance. Avoid manual certificate deployment where practical.
  • Automate certificate renewal. Renewal should occur well before expiration.
  • Monitor expiration continuously. Alert with enough time to investigate failed automation.
  • Protect private keys. Limit storage and access to components that require them.
  • Plan trust-chain rotation. Support overlapping trust during certificate-authority migrations.
  • Reuse TLS connections. Reduce repeated handshake latency and cryptographic work.
  • Size connection pools globally. Consider aggregate connections from all proxy and service instances.
  • Monitor handshake failures. Separate certificate, protocol, network, and application failures.
  • Monitor handshake latency. Detect network and TLS negotiation regressions.
  • Test certificate rotation. Verify that applications reload or receive renewed certificates correctly.
  • Test expired and untrusted certificates. Confirm failures are visible and fail securely.
  • Test recovery procedures. Certificate infrastructure is part of production availability and requires operational validation.

Conclusion

TLS provides confidentiality, integrity, and peer authentication for network communication. HTTPS applies those protections to HTTP, while mTLS can extend authenticated encryption to communication between internal services.

Production TLS architecture requires more than installing a certificate on a web server. TLS termination points, connection reuse, certificate validation, internal encryption, workload identity, automated renewal, trust rotation, and monitoring all affect the reliability and security of the system.

Key Takeaway: encrypt every network boundary that requires protection, authenticate the endpoint on the other side of the connection, automate certificate lifecycle management, and treat TLS infrastructure as part of both the security and availability architecture.

Author

Enjoyed this article?

Support Oleksandr Andrushchenko

Buy me a coffee

This helps Oleksandr Andrushchenko continue creating useful content

Comments (0)