Pick a color scheme
ad placeholder image ad placeholder image

SSL/TLS: Certificates and Encryption Explained

SSL (Secure Sockets Layer) and TLS (Transport Layer Security) are cryptographic protocols that provide secure communication over networks. While SSL is the older protocol, TLS is the modern standard that powers HTTPS and secures most internet traffic today. This comprehensive guide explains SSL/TLS, certificates, encryption, and how they protect your data.

What is SSL/TLS?

SSL and TLS are cryptographic protocols that encrypt data transmitted between clients and servers, ensuring confidentiality, integrity, and authentication.

SSL vs TLS

SSL (Secure Sockets Layer):

SSL 1.0: Never released (flawed)
SSL 2.0: Released 1995, deprecated 2011
SSL 3.0: Released 1996, deprecated 2015
Status: All versions insecure, obsolete

TLS (Transport Layer Security):

TLS 1.0: Released 1999, deprecated 2020
TLS 1.1: Released 2006, deprecated 2020
TLS 1.2: Released 2008, current standard
TLS 1.3: Released 2018, latest version
Status: TLS 1.2 and 1.3 secure

Common terminology:

"SSL certificate" = Actually TLS certificate
"SSL/TLS" = Modern TLS protocol
"SSL" = Legacy term, means TLS now

Learn more about HTTP vs HTTPS and SSH.

Purpose and Benefits

Encryption:

Confidentiality: Data unreadable to eavesdroppers
Protection: Against man-in-the-middle attacks
Privacy: Sensitive information secured

Authentication:

Server identity: Verified via certificates
Trust: Certificate Authority validation
Prevention: Impersonation attacks blocked

Integrity:

Tamper detection: Modified data detected
Verification: Message authentication codes
Assurance: Data arrives unchanged

How SSL/TLS Works

TLS Handshake

TLS 1.2 Handshake (simplified):

Client                                Server
  |                                     |
  |--- ClientHello ------------------->|
  |    (supported ciphers, TLS version)|
  |                                     |
  |<-- ServerHello --------------------|
  |    (selected cipher, certificate)  |
  |                                     |
  |<-- Certificate --------------------|
  |    (server's SSL certificate)      |
  |                                     |
  |<-- ServerHelloDone ----------------|
  |                                     |
  |--- ClientKeyExchange ------------->|
  |    (encrypted pre-master secret)   |
  |                                     |
  |--- ChangeCipherSpec -------------->|
  |                                     |
  |--- Finished --------------------->|
  |    (encrypted handshake summary)   |
  |                                     |
  |<-- ChangeCipherSpec ---------------|
  |                                     |
  |<-- Finished -----------------------|
  |    (encrypted handshake summary)   |
  |                                     |
  |=== Encrypted Application Data ===>|
  |<== Encrypted Application Data =====|

TLS 1.3 Handshake (faster):

Client                                Server
  |                                     |
  |--- ClientHello ------------------->|
  |    (key share, supported groups)   |
  |                                     |
  |<-- ServerHello --------------------|
  |    (key share, certificate)        |
  |<-- Finished -----------------------|
  |                                     |
  |--- Finished ---------------------->|
  |                                     |
  |=== Encrypted Application Data ===>|

Improvements:
- 1-RTT (one round trip)
- 0-RTT resumption (zero round trip)
- Faster connection establishment

Encryption Methods

Asymmetric encryption (handshake):

Purpose: Establish secure connection
Method: Public/private key pairs
Algorithm: RSA, ECDSA, EdDSA
Use: Key exchange, authentication
Speed: Slow

Example:

Server has:
- Public key (shared with everyone)
- Private key (kept secret)

Client:
1. Encrypts data with server's public key
2. Sends encrypted data
3. Only server's private key can decrypt

Symmetric encryption (data transfer):

Purpose: Encrypt bulk data
Method: Shared session key
Algorithm: AES, ChaCha20
Use: Application data
Speed: Fast

Example:

After handshake:
1. Both sides have same session key
2. Encrypt data with session key
3. Decrypt data with same session key
4. Fast encryption/decryption

Cipher Suites

Format:

TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256

Components:
TLS: Protocol
ECDHE: Key exchange (Elliptic Curve Diffie-Hellman Ephemeral)
RSA: Authentication
AES_128_GCM: Encryption (AES 128-bit, GCM mode)
SHA256: Message authentication

Modern cipher suites (TLS 1.3):

TLS_AES_256_GCM_SHA384
TLS_CHACHA20_POLY1305_SHA256
TLS_AES_128_GCM_SHA256
TLS_AES_128_CCM_SHA256

Secure cipher suite characteristics:

Forward secrecy: ECDHE, DHE
Strong encryption: AES-256, ChaCha20
Authenticated: GCM, Poly1305
Modern hash: SHA256, SHA384

Insecure (avoid):

RC4: Broken
3DES: Weak
MD5: Broken
NULL: No encryption
EXPORT: Deliberately weakened

SSL/TLS Certificates

What is an SSL Certificate?

An SSL certificate is a digital document that:

Verifies server identity
Contains public key
Issued by Certificate Authority (CA)
Enables encrypted connections
Establishes trust

Certificate Contents

Standard fields:

Subject: Domain name (example.com)
Issuer: Certificate Authority
Valid From: Start date
Valid To: Expiration date
Public Key: Server's public key
Signature: CA's digital signature
Serial Number: Unique identifier

Example certificate:

Subject: CN=www.example.com
Issuer: CN=Let's Encrypt Authority X3
Valid From: 2024-01-01 00:00:00
Valid To: 2024-04-01 00:00:00
Public Key Algorithm: RSA 2048 bits
Signature Algorithm: SHA256-RSA

Certificate Types

By validation level:

Domain Validated (DV):

Validation: Domain ownership only
Process: Automated (email, DNS, HTTP)
Time: Minutes to hours
Cost: Free to $50/year
Trust: Basic
Use: Blogs, personal sites, small business
Provider: Let's Encrypt, commercial CAs

Organization Validated (OV):

Validation: Domain + organization verification
Process: Manual verification
Time: 1-3 days
Cost: $50-$200/year
Trust: Medium
Use: Business websites, e-commerce
Display: Organization name in certificate

Extended Validation (EV):

Validation: Extensive verification
Process: Rigorous identity verification
Time: 1-2 weeks
Cost: $200-$1000/year
Trust: Highest
Use: Banks, large e-commerce
Display: Organization name (browser-dependent)

By coverage:

Single domain:

Covers: example.com
Also covers: www.example.com (usually)
Cost: Lowest
Use: Single website

Wildcard:

Covers: *.example.com
Includes: blog.example.com, shop.example.com
Excludes: example.com (need separate)
Cost: Higher
Use: Multiple subdomains

Multi-domain (SAN):

Covers: Multiple domains
Example: example.com, example.net, example.org
Limit: Usually 100-250 domains
Cost: Varies
Use: Multiple websites

Certificate Authorities (CAs)

Major CAs:

Let's Encrypt:

Cost: Free
Automation: ACME protocol
Validation: DV only
Renewal: Every 90 days
Trust: Widely trusted
Use: Most websites

Commercial CAs:

DigiCert: Premium, EV available
Sectigo (Comodo): Affordable
GlobalSign: International
GoDaddy: Popular, affordable
SSL.com: Various options

Root CAs:

Pre-installed in browsers/OS
Ultimate trust anchors
Rarely issue certificates directly
Sign intermediate CAs

Certificate chain:

Root CA Certificate (trusted by browsers)
  ↓ signs
Intermediate CA Certificate
  ↓ signs
Server Certificate (your website)

Certificate Lifecycle

Issuance:

1. Generate Certificate Signing Request (CSR)
2. Submit CSR to CA
3. Complete validation
4. CA issues certificate
5. Install certificate on server

Renewal:

Before expiration:
1. Generate new CSR (or reuse)
2. Request renewal
3. Validation (may be simplified)
4. Install new certificate
5. Remove old certificate

Revocation:

Reasons:
- Private key compromised
- Certificate misused
- Organization change
- Validation error

Methods:
- Certificate Revocation List (CRL)
- Online Certificate Status Protocol (OCSP)

Obtaining SSL Certificates

Let's Encrypt (Free)

Using Certbot:

Installation:

# Debian/Ubuntu
sudo apt install certbot python3-certbot-apache

# RHEL/CentOS
sudo yum install certbot python3-certbot-nginx

Obtain certificate:

# Apache (automatic configuration)
sudo certbot --apache -d example.com -d www.example.com

# Nginx (automatic configuration)
sudo certbot --nginx -d example.com -d www.example.com

# Standalone (manual server config)
sudo certbot certonly --standalone -d example.com

# Webroot (existing web server)
sudo certbot certonly --webroot -w /var/www/html -d example.com

DNS challenge (wildcards):

sudo certbot certonly --manual --preferred-challenges dns -d example.com -d *.example.com

# Add TXT record to DNS:
_acme-challenge.example.com. TXT "validation-string"

Auto-renewal:

# Test renewal
sudo certbot renew --dry-run

# Cron job
0 0 * * * certbot renew --quiet --post-hook "systemctl reload nginx"

Commercial CA

Process:

1. Generate CSR
2. Purchase certificate
3. Submit CSR
4. Complete validation
5. Download certificate
6. Install on server

Generate CSR (OpenSSL):

openssl req -new -newkey rsa:2048 -nodes \
  -keyout example.com.key \
  -out example.com.csr

# Enter details:
Country: US
State: California
City: San Francisco
Organization: Example Inc
Common Name: example.com

CSR contents:

-----BEGIN CERTIFICATE REQUEST-----
MIICvDCCAaQCAQAwdzELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWEx
...
-----END CERTIFICATE REQUEST-----

Installing SSL Certificates

Apache

Configuration:

<VirtualHost *:443>
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/html

    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/example.com.crt
    SSLCertificateKeyFile /etc/ssl/private/example.com.key
    SSLCertificateChainFile /etc/ssl/certs/intermediate.crt

    # Modern configuration
    SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
    SSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256
    SSLHonorCipherOrder off
    SSLSessionTickets off

    # HSTS
    Header always set Strict-Transport-Security "max-age=63072000"
</VirtualHost>

Enable SSL module:

sudo a2enmod ssl
sudo a2enmod headers
sudo systemctl restart apache2

Nginx

Configuration:

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name example.com www.example.com;

    ssl_certificate /etc/ssl/certs/example.com.crt;
    ssl_certificate_key /etc/ssl/private/example.com.key;
    ssl_trusted_certificate /etc/ssl/certs/chain.crt;

    # Modern configuration
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;
    ssl_prefer_server_ciphers off;

    # OCSP stapling
    ssl_stapling on;
    ssl_stapling_verify on;

    # HSTS
    add_header Strict-Transport-Security "max-age=63072000" always;

    root /var/www/html;
    index index.html;
}

Test configuration:

sudo nginx -t
sudo systemctl reload nginx

Testing Installation

OpenSSL:

# Test connection
openssl s_client -connect example.com:443 -servername example.com

# Check certificate
openssl s_client -connect example.com:443 -showcerts

# Verify certificate chain
openssl s_client -connect example.com:443 -CAfile /etc/ssl/certs/ca-certificates.crt

Online tools:

SSL Labs: ssllabs.com/ssltest
- Comprehensive analysis
- Grade A-F
- Detailed recommendations

Why No Padlock: whynopadlock.com
- Mixed content detection
- Certificate issues
- Quick diagnosis

Security Best Practices

Protocol Configuration

Enable modern protocols:

TLS 1.3: Latest, fastest, most secure
TLS 1.2: Current standard, widely supported
Disable: SSL 2.0, SSL 3.0, TLS 1.0, TLS 1.1

Apache:

SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1

Nginx:

ssl_protocols TLSv1.2 TLSv1.3;

Cipher Suite Selection

Modern ciphers:

ECDHE-ECDSA-AES256-GCM-SHA384
ECDHE-RSA-AES256-GCM-SHA384
ECDHE-ECDSA-CHACHA20-POLY1305
ECDHE-RSA-CHACHA20-POLY1305
ECDHE-ECDSA-AES128-GCM-SHA256
ECDHE-RSA-AES128-GCM-SHA256

Mozilla SSL Configuration Generator:

Website: ssl-config.mozilla.org
Profiles: Modern, Intermediate, Old
Recommendations: Server-specific

HSTS (HTTP Strict Transport Security)

Purpose:

Force HTTPS connections
Prevent protocol downgrade attacks
Protect against SSL stripping
Improve security

Header:

Strict-Transport-Security: max-age=31536000; includeSubDomains; preload

Parameters:

max-age: Duration in seconds (1 year = 31536000)
includeSubDomains: Apply to all subdomains
preload: Submit to HSTS preload list

Apache:

Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"

Nginx:

add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;

HSTS Preload:

Website: hstspreload.org
Effect: Browsers always use HTTPS
Requirement: HSTS header with preload
Caution: Difficult to remove

OCSP Stapling

Purpose:

Faster certificate validation
Privacy improvement
Reduced load on CA
Better performance

How it works:

1. Server queries OCSP responder
2. Server caches response
3. Server "staples" response to handshake
4. Client validates without contacting CA

Apache:

SSLUseStapling on
SSLStaplingCache shmcb:/var/run/ocsp(128000)

Nginx:

ssl_stapling on;
ssl_stapling_verify on;
ssl_trusted_certificate /path/to/chain.crt;
resolver 8.8.8.8 8.8.4.4 valid=300s;

Certificate Pinning

Purpose:

Prevent CA compromise
Additional security layer
Protect against rogue certificates

Methods:

HTTP Public Key Pinning (HPKP): Deprecated
Certificate Transparency: Modern approach
Expect-CT header: Transitional

Caution:

Risk of lockout
Backup pins required
Complex management
Use with extreme care

Common Issues

Certificate Errors

Expired certificate:

Error: Certificate has expired
Solution: Renew certificate
Prevention: Automated renewal

Name mismatch:

Error: Certificate name doesn't match
Cause: Wrong domain in certificate
Solution: Get certificate for correct domain

Untrusted CA:

Error: Certificate not trusted
Cause: Missing intermediate certificate
Solution: Install complete certificate chain

Self-signed certificate:

Error: Self-signed certificate
Cause: Not issued by trusted CA
Solution: Get certificate from trusted CA

Mixed Content

Problem:

HTTPS page loading HTTP resources
Browser blocks or warns
Security degraded

Detection:

Browser console
Developer tools
Online scanners (whynopadlock.com)

Fix:

Update all resources to HTTPS
Use protocol-relative URLs
Content Security Policy

Performance Issues

Slow handshake:

Cause: Large certificate chain
Solution: Optimize chain, enable OCSP stapling

High CPU usage:

Cause: Encryption overhead
Solution: Hardware acceleration, session resumption

Session resumption:

TLS session tickets
Session ID caching
Reduces handshake overhead

Monitoring and Maintenance

Certificate Expiration

Monitoring:

Automated checks
Alert 30 days before expiration
Multiple notification channels

Tools:

SSL Labs monitoring
Uptime monitors (UptimeRobot)
Custom scripts
Certificate Transparency logs

Script example:

#!/bin/bash
DOMAIN="example.com"
EXPIRY=$(echo | openssl s_client -servername $DOMAIN -connect $DOMAIN:443 2>/dev/null | openssl x509 -noout -enddate | cut -d= -f2)
EXPIRY_EPOCH=$(date -d "$EXPIRY" +%s)
NOW_EPOCH=$(date +%s)
DAYS_LEFT=$(( ($EXPIRY_EPOCH - $NOW_EPOCH) / 86400 ))

if [ $DAYS_LEFT -lt 30 ]; then
    echo "Certificate expires in $DAYS_LEFT days!"
fi

Security Audits

Regular testing:

SSL Labs scan monthly
Cipher suite review
Protocol version check
Vulnerability scanning

Update schedule:

Security patches: Immediately
Certificate renewal: Before expiration
Configuration review: Quarterly
Protocol updates: As released

Conclusion

SSL/TLS certificates and encryption are fundamental to internet security, protecting data in transit and verifying server identity. Modern TLS 1.2 and 1.3 provide strong security when properly configured, and free certificates from Let's Encrypt have made HTTPS accessible to all websites.


Related Articles

Web Security

Protocols

Privacy and Security

Explore More

Key takeaways: - TLS 1.2/1.3 are current secure versions - SSL is obsolete, term persists - Certificates verify identity and enable encryption - Let's Encrypt provides free, automated certificates - Proper configuration essential for security - HSTS enforces HTTPS connections - OCSP stapling improves performance - Regular monitoring prevents expiration - Mixed content must be avoided - Certificate chain must be complete

Implementing SSL/TLS correctly requires obtaining valid certificates, configuring modern protocols and ciphers, enabling security headers like HSTS, and maintaining certificates through automated renewal. With free certificates and automated tools, there's no excuse for not using HTTPS on every website.

ad placeholder image ad placeholder image
Three funny piglies - an illustration ippigly.com