Skip to content

Checking your reading list…

Retry

Stay curious. Build better.

Appearance

Choose how BestHub looks on this device.

Changes apply immediately.

Search articles

Open Discover with these filters

Suggested searches

Operations
22 min read

Diagnosing Slow HTTPS Handshakes: Certificate, Network, or Cipher Suite?

This comprehensive guide provides a systematic troubleshooting framework for slow HTTPS handshakes, covering TCP/TLS handshake analysis, certificate chain validation, OCSP stapling, cipher suite selection, session reuse, and production-ready monitoring with practical command examples for Nginx and Apache.

Problem Background

In production environments, slow HTTPS API responses are often initially blamed on application-layer issues, but the handshake phase itself can consume significant time. Slow handshakes may stem from long certificate chains, high network RTT, slow cipher suite negotiation, OCSP query delays, and other factors. This article targets junior to mid-level operations engineers, providing a complete troubleshooting methodology and verification methods to quickly pinpoint the root cause of slow HTTPS handshakes.

Applicable Scenarios

HTTPS first-request latency significantly higher than subsequent requests

Client reports slow SSL connection establishment

Monitoring shows abnormal SSL handshake times

High backend handshake latency behind CDN or load balancer

High latency for cross-region HTTPS access

Handshake performance degrades after certificate renewal

Large handshake time variance across different clients

Core Knowledge

3.1 HTTPS Handshake Process

The full handshake comprises:

TCP three-way handshake

TLS ClientHello

TLS ServerHello + Certificate + ServerKeyExchange + ServerHelloDone

TLS ClientKeyExchange + ChangeCipherSpec + Finished

TLS ChangeCipherSpec + Finished

Each stage can become a bottleneck.

3.2 Handshake Time Breakdown

Network RTT : TCP handshake and TLS message round-trips

Certificate Verification : Client validates certificate chain, OCSP/CRL queries

Key Exchange : RSA decryption or ECDHE computation

Cipher Suite Negotiation : Client and server algorithm selection

Session Reuse : Session ID, Session Ticket, TLS 1.3 0-RTT

3.3 Common Bottlenecks

High Network RTT : All connections slow, algorithm-independent; global impact

Long Certificate Chain : First handshake slow, reuse normal; affects first connection

OCSP Query Stalls : Intermittent slowness, possible timeouts; partial connections

Weak Cipher Suites : High CPU usage, slow server response; server-side impact

Session Reuse Failure : Every connection performs full handshake; all connections affected

Overall Troubleshooting Approach

4.1 Investigation Path

1. Confirm handshake slowness phenomenon
  ↓
2. Separate TCP and TLS handshake times
  ↓
3. Determine network vs protocol issue
  ↓
4. Check certificate chain and OCSP
  ↓
5. Check cipher suites and protocol versions
  ↓
6. Check session reuse configuration
  ↓
7. Verify fix effectiveness
  ↓
8. Prepare rollback plan

4.2 Decision Logic

If TCP handshake slow → network issue

If TLS handshake slow but TCP normal → protocol or certificate issue

If only first handshake slow → certificate validation or OCSP issue

If every handshake slow → session reuse failure or cipher suite issue

If server CPU high → encryption computation load

Practical Steps

5.1 Confirm Handshake Slowness

5.1.1 Using curl to Measure Handshake Time

curl -w "
DNS: %{time_namelookup}s
TCP: %{time_connect}s
TLS: %{time_appconnect}s
Total: %{time_total}s
" -o /dev/null -s https://example.com

Key Metrics: time_namelookup: DNS resolution time time_connect: TCP handshake completion (includes DNS) time_appconnect: TLS handshake completion (includes TCP) time_total: Total time

Calculations: time_connect - time_namelookup = TCP handshake time time_appconnect - time_connect = TLS handshake time

Anomaly Indicators:

TLS handshake > 500ms → priority investigation

TLS handshake > 10x TCP handshake → protocol layer issue

Large variance across tests → possible unstable OCSP queries

5.1.2 Using openssl for Handshake Details

openssl s_client -connect example.com:443 -tls1_2 -time

Observation Points: Certificate chain depth: >3 layers may impact performance SSL handshake has read X bytes: Large read indicates long certificate chain Cipher is XXX: Cipher suite type

Connection establishment time

5.1.3 Packet Capture with tcpdump

tcpdump -i eth0 -nn -s0 -w /tmp/https_handshake.pcap 'host example.com and port 443'

Analyze with Wireshark: filter ssl.handshake, check Statistics → Conversations → TCP, focus on Duration column. Key timestamps: SYN→SYN-ACK→ACK (TCP handshake), Client Hello→Server Hello (TLS negotiation), Certificate message size (certificate chain length), Server Finished→Client Finished (key exchange time).

5.2 Separate TCP and TLS Handshake Times

5.2.1 Test TCP Handshake Time

time nc -zv example.com 443
real

time = TCP handshake time. If >100ms, prioritize network investigation.

5.2.2 Test Pure TLS Handshake Time

(time openssl s_client -connect example.com:443 -brief) 2>&1 | grep real

TLS pure handshake time = openssl total time - TCP handshake time. Example: 234ms - 45ms = 189ms. TLS pure handshake >200ms → investigate certificate or cipher suites; <50ms → normal.

5.3 Determine Network vs Protocol Issue

5.3.1 Test RTT

ping -c 10 example.com

Average RTT × 2 ≈ TCP handshake time (theoretical). If TCP handshake far exceeds 2×RTT → network congestion or packet loss.

5.3.2 Test MTR Routing

mtr -r -c 50 example.com

Key metrics: Loss% (packet loss >1% needs attention), Last/Avg/Best/Wrst latency stats. Identify which hop shows loss or latency spike.

5.3.3 Compare Handshake Times Across Regions

Run curl tests from servers in different regions. If all regions slow → server issue; only some regions slow → network routing; cross-border slow → international egress bandwidth or GFW impact.

5.4 Check Certificate Chain and OCSP

5.4.1 View Certificate Chain Depth

openssl s_client -connect example.com:443 -showcerts < /dev/null 2>/dev/null | grep -c "BEGIN CERTIFICATE"

Depth 2-3 → normal; ≥4 → may impact performance; redundant intermediate certificates → optimize.

5.4.2 Extract and Inspect Each Certificate

openssl s_client -connect example.com:443 -showcerts < /dev/null 2>/dev/null | awk '/BEGIN CERTIFICATE/,/END CERTIFICATE/ {print}' > /tmp/cert_chain.pem
csplit -f /tmp/cert- /tmp/cert_chain.pem '/BEGIN CERTIFICATE/' '{*}'
for cert in /tmp/cert-*; do if grep -q "BEGIN CERTIFICATE" "$cert"; then echo "=== $cert ==="; openssl x509 -in "$cert" -noout -subject -issuer; fi; done

Check for chain breaks (issuer/subject mismatch), self-signed non-root certificates, expired certificates (check notAfter).

5.4.3 Check OCSP Response Time

openssl s_client -connect example.com:443 -status < /dev/null 2>/dev/null | grep -A 20 "OCSP Response Status"

No OCSP response → OCSP Stapling possibly disabled. Cert Status: revoked → certificate revoked. Next Update expired → OCSP response stale.

5.4.4 Test OCSP Server Response Time

OCSP_URL=$(openssl s_client -connect example.com:443 < /dev/null 2>/dev/null | openssl x509 -noout -ocsp_uri)
time curl -I $OCSP_URL

Response >500ms → slow OCSP server; timeout → client may stall on OCSP query; 405/200 → service normal (OCSP doesn't support HEAD).

5.4.5 Verify Server OCSP Stapling

openssl s_client -connect example.com:443 -status -tlsextdebug < /dev/null 2>&1 | grep -i "ocsp"

Presence of OCSP response → stapling enabled; absence → disabled, client must query OCSP independently, adding latency especially if OCSP server overseas or unstable.

5.5 Check Cipher Suites and Protocol Versions

5.5.1 List Server-Supported Cipher Suites

nmap --script ssl-enum-ciphers -p 443 example.com

Check: TLS 1.3 support, weak suites (grade C or lower), ECDHE priority over RSA. Anomalies: only RSA key exchange → poor performance; CBC mode high priority → BEAST/Lucky13 risk; 3DES/RC4 → severe security risk.

5.5.2 Test Specific Cipher Suite Handshake Times

# Test ECDHE-RSA-AES128-GCM-SHA256
time openssl s_client -connect example.com:443 -cipher ECDHE-RSA-AES128-GCM-SHA256 -brief < /dev/null
# Test TLS 1.3
time openssl s_client -connect example.com:443 -tls1_3 -brief < /dev/null

Compare RSA vs ECDHE, TLS 1.2 vs 1.3. ECDHE faster → prefer ECDHE; TLS 1.3 faster → upgrade; specific suite slow → server compute load high.

5.5.3 Check Server CPU Load

top -b -n 1 | grep -E "Cpu|nginx|openssl"
perf top -p $(pgrep nginx | head -1)

High nginx/openssl CPU → encryption load heavy. High system ( sy) percentage → frequent key exchanges. Key symbols: __ssl3_read_bytes, ssl3_accept, RSA_private_decrypt, EC_KEY_generate_key indicate handshake computation bottleneck.

5.6 Check Session Reuse Configuration

5.6.1 Test Session ID Reuse

echo "Q" | openssl s_client -connect example.com:443 -reconnect 2>&1 | grep -E "Session-ID:|Reused"

First connection: non-empty Session-ID; subsequent: Reused appears. No Reused → session reuse not working.

5.6.2 Test Session Ticket Reuse

openssl s_client -connect example.com:443 -sess_out /tmp/session.pem < /dev/null
openssl s_client -connect example.com:443 -sess_in /tmp/session.pem -brief < /dev/null
Reused

→ ticket valid; no Reused → ticket expired or server config issue.

5.6.3 Check Server Session Config (Nginx Example)

grep -E "ssl_session|ssl_stapling" /etc/nginx/nginx.conf

Expected: ssl_session_cache shared:SSL:10m (10MB shared cache), ssl_session_timeout 10m, ssl_session_tickets on, ssl_stapling on, ssl_stapling_verify on. Bad configs: ssl_session_cache off (reuse disabled), ssl_session_timeout 1m (too short), ssl_session_tickets off (no ticket mechanism).

5.7 Compare Different Client Handshake Behavior

5.7.1 Test with Different Tools

# curl
curl -w "TLS: %{time_appconnect}s
" -o /dev/null -s https://example.com
# wget
time wget --no-check-certificate -q -O /dev/null https://example.com
# openssl
time openssl s_client -connect example.com:443 -brief < /dev/null

Record times; curl slow but openssl fast → curl version or CA cert issue; all slow → server or network.

5.7.2 Test Different TLS Libraries

openssl version
gnutls-cli --print-cert example.com:443 < /dev/null

Different TLS library implementations may cause performance differences, especially in key exchange algorithm optimizations.

5.8 Deep Packet Analysis of Handshake Details

5.8.1 Capture Full Handshake

tcpdump -i eth0 -nn -s0 -w /tmp/tls_handshake.pcap 'host example.com and port 443' &
TCPDUMP_PID=$!
curl -o /dev/null -s https://example.com
kill $TCPDUMP_PID

5.8.2 Analyze Handshake Times with tshark

tshark -r /tmp/tls_handshake.pcap -Y "ssl.handshake" -T fields -e frame.time_relative -e ssl.handshake.type

Handshake types: 1=Client Hello, 2=Server Hello, 11=Certificate, 12=Server Key Exchange, 14=Server Hello Done, 16=Client Key Exchange, 20=Finished. Time analysis: 0.000000→0.045123 = network RTT (Client Hello→Server Hello); 0.045123→0.045456 = server processing (certificate + key exchange); 0.045456→0.089678 = network RTT (Server Done→Client Key Exchange); 0.089678→0.089789 = client processing (key exchange + Finished). If network RTT dominates → network issue; server processing long → server compute/I/O slow; client processing long → client performance issue.

5.8.3 Analyze Certificate Transfer Size

tshark -r /tmp/tls_handshake.pcap -Y "ssl.handshake.certificate" -T fields -e frame.len

Certificate message >2000 bytes → long chain; >4000 bytes → may fragment, adding RTT.

5.9 Verify Fix Effectiveness

5.9.1 Before/After Comparison

# Before fix
for i in {1..10}; do curl -w "TLS: %{time_appconnect}s
" -o /dev/null -s https://example.com; done | awk '{sum+=$2; count++} END {print "Average:", sum/count, "s"}'
# Apply fix
# After fix
for i in {1..10}; do curl -w "TLS: %{time_appconnect}s
" -o /dev/null -s https://example.com; done | awk '{sum+=$2; count++} END {print "Average:", sum/count, "s"}'

Record average handshake time and standard deviation.

5.9.2 Multi-Region Verification

Run same tests from multiple regions to ensure global effectiveness.

5.9.3 Production Traffic Observation

Monitor: SSL handshake duration, SSL handshake errors, SSL session reuse rate. Prometheus example queries provided.

Common Command Summary

6.1 Handshake Test Commands

# Basic handshake test
curl -w "
TLS: %{time_appconnect}s
" -o /dev/null -s https://example.com
# Detailed handshake info
openssl s_client -connect example.com:443 -tls1_2 -status
# Test session reuse
echo "Q" | openssl s_client -connect example.com:443 -reconnect
# Test specific cipher
openssl s_client -connect example.com:443 -cipher ECDHE-RSA-AES128-GCM-SHA256
# Test TLS 1.3
openssl s_client -connect example.com:443 -tls1_3

6.2 Certificate Check Commands

# View certificate chain
openssl s_client -connect example.com:443 -showcerts < /dev/null
# Check expiry
openssl s_client -connect example.com:443 < /dev/null 2>/dev/null | openssl x509 -noout -dates
# Check OCSP response
openssl s_client -connect example.com:443 -status < /dev/null 2>/dev/null | grep -A 20 "OCSP"
# Extract OCSP URL
openssl s_client -connect example.com:443 < /dev/null 2>/dev/null | openssl x509 -noout -ocsp_uri

6.3 Cipher Suite Check Commands

# List server-supported ciphers
nmap --script ssl-enum-ciphers -p 443 example.com
# Test specific suite
openssl s_client -connect example.com:443 -cipher 'ECDHE-RSA-AES128-GCM-SHA256'
# List client-supported suites
openssl ciphers -v 'ALL'

6.4 Network Test Commands

# Test TCP handshake
time nc -zv example.com 443
# Test RTT
ping -c 10 example.com
# Test routing
mtr -r -c 50 example.com
# Packet capture
tcpdump -i eth0 -nn -s0 -w /tmp/tls.pcap 'host example.com and port 443'

6.5 Server Check Commands (Nginx)

# Check SSL config
grep -E "ssl_" /etc/nginx/nginx.conf
# Test config syntax
nginx -t
# Reload config
nginx -s reload
# View SSL module info
nginx -V 2>&1 | grep -o with-http_ssl_module

Configuration Examples

7.1 Nginx Optimized Configuration

7.1.1 Complete SSL Optimization

http {
  # SSL Session Cache
  ssl_session_cache shared:SSL:50m;
  ssl_session_timeout 1h;
  ssl_session_tickets on;
  # OCSP Stapling
  ssl_stapling on;
  ssl_stapling_verify on;
  ssl_stapling_file /var/cache/nginx/ocsp.resp;
  # Protocol versions
  ssl_protocols TLSv1.2 TLSv1.3;
  # Cipher suite priority
  ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305';
  ssl_prefer_server_ciphers off;
  # DH parameters
  ssl_dhparam /etc/nginx/dhparam.pem;
  # Certificate and key
  ssl_certificate /etc/nginx/ssl/fullchain.pem;
  ssl_certificate_key /etc/nginx/ssl/privkey.pem;
  # Performance
  ssl_buffer_size 4k;
  server {
    listen 443 ssl http2;
    server_name example.com;
    # other config
  }
}

Key settings: 50MB shared cache (~200k sessions), 1-hour timeout, TLS 1.2/1.3 only, ECDHE preferred, ssl_prefer_server_ciphers off for TLS 1.3 client choice, 4k buffer for small certs.

7.1.2 Generate DH Parameters

openssl dhparam -out /etc/nginx/dhparam.pem 2048

2048-bit takes minutes; 4096-bit more secure but slower handshake; reference in Nginx config after generation.

7.2 Apache Optimized Configuration

<VirtualHost *:443>
  ServerName example.com
  SSLEngine on
  SSLCertificateFile /etc/ssl/certs/fullchain.pem
  SSLCertificateKeyFile /etc/ssl/private/privkey.pem
  SSLProtocol -all +TLSv1.2 +TLSv1.3
  SSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384
  SSLHonorCipherOrder off
  SSLSessionCache "shmcb:/var/cache/mod_ssl/scache(512000)"
  SSLSessionCacheTimeout 3600
  SSLUseStapling on
  SSLStaplingResponderTimeout 5
  SSLStaplingReturnResponderErrors off
  SSLStaplingCache "shmcb:/var/cache/mod_ssl/stapling(128000)"
</VirtualHost>

7.3 Generate Optimized Certificate Chain

7.3.1 Merge Certificate Chain

# Correct order: server cert → intermediate cert
cat cert.pem chain.pem > fullchain.pem

Do not include root cert (client has it). Verify order:

openssl crl2pkcs7 -nocrl -certfile fullchain.pem | openssl pkcs7 -print_certs -noout

.

7.4 Configure OCSP Stapling Cache

7.4.1 Manual OCSP Response Fetch (Nginx)

OCSP_URL=$(openssl x509 -in /etc/nginx/ssl/fullchain.pem -noout -ocsp_uri)
openssl ocsp -no_nonce -issuer /etc/nginx/ssl/chain.pem -cert /etc/nginx/ssl/cert.pem -url "$OCSP_URL" -respout /var/cache/nginx/ocsp.resp

Auto-update script (run via cron every 6 hours) fetches new response, replaces if valid, reloads Nginx.

Log and Metrics Observation

8.1 Nginx Access Log Analysis

8.1.1 Custom Log Format for Handshake Info

log_format ssl_timing '$remote_addr - $remote_user [$time_local] '
  '"$request" $status $body_bytes_sent '
  '"$http_referer" "$http_user_agent" '
  'ssl_protocol=$ssl_protocol ssl_cipher=$ssl_cipher '
  'ssl_session_reused=$ssl_session_reused '
  'request_time=$request_time';
access_log /var/log/nginx/ssl_access.log ssl_timing;

8.1.2 Analyze Session Reuse Rate

awk '{print $NF}' /var/log/nginx/ssl_access.log | grep -o 'ssl_session_reused=[^ ]*' | sort | uniq -c

Output: 1234 ssl_session_reused=r (reused), 567 ssl_session_reused=. (not reused). Reuse rate = r count / total. >80% normal; <50% indicates session config issues.

8.2 SSL Error Logs

grep -i "ssl" /var/log/nginx/error.log | tail -50

Common errors: SSL_do_handshake() failed (handshake failure), peer closed connection in SSL handshake (client abort), ssl_stapling: OCSP responder timed out (OCSP timeout), SSL_CTX_use_PrivateKey_file() failed (private key issue).

8.3 Monitoring Metrics (Prometheus + Nginx VTS)

8.3.1 Nginx VTS Module Config

http { vhost_traffic_status_zone; server { listen 9145; location /status { vhost_traffic_status_display; vhost_traffic_status_display_format prometheus; } } }

8.3.2 Prometheus Scrape Config

scrape_configs:
- job_name: 'nginx'
  static_configs:
  - targets: ['nginx-server:9145']

8.3.3 Common Queries

# SSL handshake P95
histogram_quantile(0.95, rate(nginx_vts_server_request_duration_seconds_bucket{stage="ssl"}[5m]))
# SSL handshake error rate
rate(nginx_vts_server_requests_total{code=~"4..|5.."}[5m]) / rate(nginx_vts_server_requests_total[5m])
# Session reuse rate
sum(rate(nginx_ssl_session_reused_total[5m])) / sum(rate(nginx_ssl_handshakes_total[5m]))

Metric names may need adjustment per exporter.

8.4 Trace Handshake Syscalls with strace

strace -p $(pgrep -f "nginx: worker" | head -1) -e trace=network -s 256 -f

Key syscalls: accept() (accept connection), setsockopt() (socket options), read()/recvfrom() (receive), write()/sendto() (send). Frequent EAGAIN on read → network slow; write blocking → send buffer full.

Troubleshooting Paths by Scenario

9.1 Scenario 1: All Connections Slow

Path: Test RTT → if normal, check server CPU → if high, check cipher suites → if normal, check session reuse → if normal, check certificate chain length. Causes: high network latency, heavy server encryption load, poor cipher choice, session reuse failure.

9.2 Scenario 2: Only First Handshake Slow

Path: Check session reuse → if normal, check certificate chain → check OCSP query time → check client CA store. Causes: long certificate chain, slow OCSP, slow client cert validation.

9.3 Scenario 3: Intermittent Slowness

Path: Capture slow connections → check OCSP server stability → check network packet loss → check server load fluctuations. Causes: unstable OCSP, network congestion/loss, server load spikes.

9.4 Scenario 4: Specific Client Slow

Path: Compare client handshake times → check client protocol versions → check client cipher suites → check client network path. Causes: old TLS library, weak cipher support, poor client network.

9.5 Scenario 5: Cross-Region Slow

Path: Compare regional RTTs → check international egress bandwidth → consider CDN/edge deployment → enable TLS 1.3 to reduce RTT. Causes: high inter-region latency, international congestion, lack of edge acceleration.

Risk Warnings

10.1 Cipher Suite Changes

Risks: disabling suites may break old clients; priority misconfiguration may reduce security; TLS 1.3 only may cause failures. Mitigation: backup config, test in staging, gradual rollout, monitor handshake failure rate.

10.2 Session Config Changes

Risks: long timeout increases memory; small cache lowers reuse; ticket key leak enables session hijacking. Mitigation: size cache per connection count, rotate ticket keys regularly, monitor memory.

10.3 OCSP Stapling Enablement

Risks: expired OCSP response causes client rejection; OCSP server outage affects handshake; revoked cert not updated in stapled response. Mitigation: auto-update OCSP response, set reasonable timeout, monitor response validity.

10.4 Certificate Replacement

Risks: longer chain slows handshake; malformed cert causes failure; incorrect private key permissions prevent startup. Mitigation: validate chain integrity pre-swap, check key permissions (600), test new cert handshake time, keep old cert for rollback.

10.5 Network Parameter Tuning

Risks: TCP changes affect other services; MTU changes break connectivity; firewall changes impact reachability. Mitigation: test in staging, record original values, phased production rollout.

Verification Methods

11.1 Functional Verification

11.1.1 Verify Handshake Success

curl -I https://example.com

Expect HTTP/2 200. Failures: timeout, SSL handshake failure, cert verification failure.

11.1.2 Verify Protocol Version

openssl s_client -connect example.com:443 -brief < /dev/null 2>&1 | grep "Protocol"

Expect Protocol version: TLSv1.3.

11.1.3 Verify Cipher Suite

openssl s_client -connect example.com:443 -brief < /dev/null 2>&1 | grep "Cipher"

Expect Cipher: TLS_AES_128_GCM_SHA256.

11.2 Performance Verification

11.2.1 Batch Handshake Time Test

for i in {1..100}; do curl -w "%{time_appconnect}
" -o /dev/null -s https://example.com; done | awk '{sum+=$1; sumsq+=$1*$1} END {avg=sum/NR; stddev=sqrt(sumsq/NR - avg*avg); print "Avg:", avg, "s, StdDev:", stddev, "s"}'

Lower average than pre-fix → improvement; low stddev → stability.

11.2.2 Verify Session Reuse Rate

for i in {1..10}; do echo "Request $i"; curl -s -o /dev/null https://example.com; done
grep ssl_session_reused /var/log/nginx/ssl_access.log | tail -10

11.3 Security Verification

11.3.1 SSL Labs Test

Visit https://www.ssllabs.com/ssltest/analyze.html?d=example.com. Check: Overall Rating (A/A+), Certificate validity, Protocol Support (TLS 1.2/1.3), Cipher Suites (no weak suites).

11.3.2 testssl.sh Test

git clone https://github.com/drwetter/testssl.sh.git
cd testssl.sh
./testssl.sh https://example.com

Checks: protocol versions, cipher security, certificate validity, OCSP stapling status.

11.4 Compatibility Verification

11.4.1 Test Different Clients

# curl
curl -I https://example.com
# wget
wget --spider https://example.com
# openssl 1.0.2
openssl s_client -connect example.com:443 -tls1_2 < /dev/null
# openssl 1.1.1
openssl s_client -connect example.com:443 -tls1_3 < /dev/null

11.4.2 Test Different Browsers

Chrome/Edge, Firefox, Safari, IE11 (if required). Verify: access works, no cert warnings, normal handshake time.

Rollback Plans

12.1 Config Rollback

12.1.1 Backup Current Config

cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup.$(date +%Y%m%d%H%M%S)
cp /etc/httpd/conf.d/ssl.conf /etc/httpd/conf.d/ssl.conf.backup.$(date +%Y%m%d%H%M%S)

12.1.2 Rollback Steps

cp /etc/nginx/nginx.conf.backup.20260101120000 /etc/nginx/nginx.conf
nginx -t
nginx -s reload
curl -I https://example.com

12.2 Certificate Rollback

cp /etc/nginx/ssl/fullchain.pem.old /etc/nginx/ssl/fullchain.pem
cp /etc/nginx/ssl/privkey.pem.old /etc/nginx/ssl/privkey.pem
nginx -s reload
openssl s_client -connect example.com:443 < /dev/null 2>/dev/null | openssl x509 -noout -dates

12.3 Network Parameter Rollback

sysctl -p /etc/sysctl.conf.backup
sysctl -a | grep -E "net.ipv4|net.core"

12.4 Rollback Verification

# Functional
curl -I https://example.com
# Performance
curl -w "TLS: %{time_appconnect}s
" -o /dev/null -s https://example.com
# Logs
tail -f /var/log/nginx/error.log

Production Considerations

13.1 Change Window Selection

Preferred: business low-peak, non-promotional, staffed hours. Avoid: peak hours, holidays, major events.

13.2 Canary Release Strategy

13.2.1 By Server

1 server → observe 1h → 10% servers → observe 2h → 50% → observe 4h → full rollout.

13.2.2 By Traffic (Nginx Example)

geo $gray_release { default 0; 10.0.0.0/24 1; # internal test }
server {
  listen 443 ssl;
  if ($gray_release = 1) { ssl_protocols TLSv1.2 TLSv1.3; }
  # other config
}

13.3 Monitoring Alerts

13.3.1 Key Metrics

SSL handshake P99 > 500ms

SSL handshake failure rate > 0.1%

Session reuse rate < 50%

Server SSL CPU > 80%

13.3.2 Prometheus Alert Rules Example

groups:
- name: ssl_alerts
  rules:
  - alert: SSLHandshakeSlow
    expr: histogram_quantile(0.99, rate(nginx_http_request_duration_seconds_bucket{stage="ssl"}[5m])) > 0.5
    for: 5m
    annotations:
      summary: "SSL handshake is slow"
      description: "P99 SSL handshake time is {{ $value }}s"
  - alert: SSLHandshakeFailure
    expr: rate(nginx_ssl_handshake_errors_total[5m]) / rate(nginx_ssl_handshakes_total[5m]) > 0.001
    for: 5m
    annotations:
      summary: "SSL handshake failure rate is high"
      description: "Failure rate is {{ $value }}"

13.4 Emergency Procedures

13.4.1 Handshake Failure Emergency

# 1. Immediate config rollback
cp /etc/nginx/nginx.conf.backup /etc/nginx/nginx.conf
nginx -s reload
# 2. Notify team
# 3. Collect logs
tar czf /tmp/ssl_logs_$(date +%Y%m%d%H%M%S).tar.gz /var/log/nginx/error.log /var/log/nginx/ssl_access.log
# 4. Root cause analysis

13.4.2 Performance Degradation Emergency

# 1. Check server load
top -b -n 1 | head -20
# 2. Check connection count
ss -s
# 3. Temporarily disable OCSP Stapling (if OCSP cause)
# edit nginx.conf, comment ssl_stapling lines
nginx -s reload
# 4. Increase session cache
# edit nginx.conf, increase ssl_session_cache
nginx -s reload

13.5 Documentation and Communication

13.5.1 Change Record

Record: change time, content, reason, impact scope, rollback plan, verification results.

13.5.2 Team Communication

Pre-change: notify ops, business, support (if user impact). Post-change: report results, share metrics, gather feedback.

Summary

14.1 Key Takeaways

Layered troubleshooting for handshake slowness : verify TCP handshake, TLS handshake, certificate validation, OCSP queries individually.

Network RTT is foundational : rule out network issues before protocol issues.

Certificate chain length affects performance : avoid redundant intermediate/root certificates.

Session reuse is critical : properly configure Session Cache and Session Ticket.

OCSP Stapling reduces latency : prevents client-independent OCSP queries.

Cipher suite choice impacts compute load : prefer ECDHE over RSA.

TLS 1.3 reduces RTT : one fewer round-trip vs TLS 1.2.

Monitoring and logs are troubleshooting basis : record handshake time, session reuse rate, error logs.

14.2 Best Practices

Enable TLS 1.3 and 1.2, disable TLS 1.0/1.1

Prioritize ECDHE cipher suites

Configure >50MB Session Cache

Set session timeout to 1 hour

Enable OCSP Stapling with auto-update

Certificate chain: only server cert + necessary intermediates

Use HTTP/2 for connection reuse

Regularly monitor handshake performance metrics

14.3 Common Misconceptions

Misconception : Handshake slowness always server-side. Fact : Could be network latency, client performance, slow OCSP, etc.

Misconception : Disabling all weak suites doesn't affect compatibility. Fact : May break old clients; balance security and compatibility.

Misconception : Shorter certificate chain always better. Fact : Must include required intermediates or client can't validate.

Misconception : Larger session cache always better. Fact : Size per actual connection count; oversizing wastes memory.

Misconception : OCSP Stapling works once enabled. Fact : Must ensure OCSP response valid and timely updated.

14.4 Advanced Directions

Deploy CDN/edge nodes to reduce network latency

Use hardware acceleration (e.g., Intel QAT) for crypto performance

Implement TLS 1.3 0-RTT to further reduce handshake time

Optimize TCP parameters (e.g., BBR congestion control)

Adopt QUIC (HTTP/3) to replace TCP+TLS

14.5 Continuous Optimization

Regularly check certificate expiry to avoid expiration

Regularly update TLS libraries and web server versions

Periodically review cipher suite configs against evolving security standards

Regularly analyze handshake performance data for potential issues

Conduct periodic security scans to ensure best-practice compliance

Through systematic troubleshooting and continuous optimization, HTTPS handshake slowness can be effectively resolved, improving user experience and service stability. Key is establishing comprehensive monitoring, mastering scientific troubleshooting methods, and maintaining robust emergency plans.

For attribution, corrections or content rights, contactadmin@besthub.dev

Report an issue with this article

Discussion 0

Questions, practical examples and thoughtful responses.

Open full discussion