Tag: Cryptography

  • TLS Configuration for Nginx and Apache: TLS 1.3, Ciphers, HSTS and Certificate Renewal

    TLS Configuration for Nginx and Apache: TLS 1.3, Ciphers, HSTS and Certificate Renewal

    TLS configuration for Nginx and Apache: TLS 1.2 and 1.3, modern ciphers, HSTS and automated certificate renewal

    Introduction

    A secure TLS configuration in 2026 means TLS 1.2 and 1.3 only, a short list of forward-secret ciphers, HSTS, and automated certificate renewal. This guide gives copy-ready settings for Nginx and Apache HTTP Server, based on the TLSRef (formerly Mozilla) guidelines, IETF RFCs and the vendor documentation.

    Two things changed this year. Public certificates are now limited to 200 days, and that limit keeps shrinking. NIST also announced on November 19, 2026, that it will revise its TLS guidance. Everything below is checked as of November 30, 2026.

    Key Facts: TLS Configuration at a Glance

    • Protocols: allow TLS 1.2 and TLS 1.3. RFC 8996 deprecated TLS 1.0 and 1.1, and RFC 9325 says implementations must not negotiate them.
    • Profile: TLSRef’s “Intermediate” profile (version 6.0) is the recommended default. “Modern” allows TLS 1.3 only.
    • Ciphers: only ECDHE key exchange with AES-GCM or ChaCha20-Poly1305. Let the client choose the order.
    • HSTS: TLSRef recommends max-age=63072000 (two years). Roll it out in stages.
    • Certificates: the maximum validity is 200 days since March 15, 2026, then 100 days from March 15, 2027 and 47 days from March 15, 2029 (CA/Browser Forum).
    • Action: pin protocols and ciphers explicitly, test from outside, and automate renewal before the limit drops again.

    What Is the Safest TLS Configuration for a Web Server?

    The safest general-purpose TLS configuration is TLSRef’s Intermediate profile. It supports TLS 1.2 and 1.3, which covers nearly every client released in the last five years, according to TLSRef. TLSRef continues the Mozilla Server Side TLS guidelines, which moved to a community working group project.

    SettingIntermediate (recommended)Modern
    ProtocolsTLS 1.2, TLS 1.3TLS 1.3 only
    CertificateECDSA P-256 (recommended) or RSA 2048ECDSA P-256
    TLS curvesX25519MLKEM768, X25519, prime256v1, secp384r1same
    HSTSmax-age=63072000max-age=63072000
    Oldest clientsFirefox 31.3, Chrome 49, Java 8u161, OpenSSL 1.0.1lFirefox 63, Chrome 70, Java 11, OpenSSL 1.1.1

    Choose Modern only if you know that every client speaks TLS 1.3. For public websites, Intermediate is the safer choice.

    Why Should You Turn Off TLS 1.0 and 1.1?

    You should turn them off because the IETF deprecated both versions in RFC 8996 (March 2021). They lack modern algorithms. RFC 9325 (BCP 195, November 2022) states that implementations must not negotiate TLS 1.0 or 1.1, must support TLS 1.2, and should support TLS 1.3 and prefer it.

    Check your defaults, because they differ by server:

    ServerDocumented defaultWhat to do
    Nginxssl_protocols TLSv1.2 TLSv1.3 (TLS 1.3 included by default since 1.23.4)Set it explicitly anyway
    Apache HTTP ServerSSLProtocol all -SSLv3Replace with an explicit TLS 1.2 and 1.3 list

    On Apache, all still includes TLS 1.0 and 1.1 when the OpenSSL library supports them. Your distribution may tighten this, but do not rely on it.

    How Do You Configure TLS in Nginx?

    Set the protocols, the TLS 1.2 cipher list and session handling in the server block. The ciphers below are TLSRef’s Intermediate list for TLS 1.2. TLS 1.3 suites are set separately: TLSRef lists three, and Nginx documents ssl_conf_command Ciphersuites if you must change them.

    server {
        listen 443 ssl;
        listen [::]:443 ssl;
        server_name example.com;
    
        ssl_certificate     /etc/ssl/example.com/fullchain.pem;
        ssl_certificate_key /etc/ssl/example.com/privkey.pem;
    
        ssl_protocols TLSv1.2 TLSv1.3;
        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;
    
        ssl_session_cache shared:SSL:10m;
        ssl_session_timeout 1d;
        ssl_session_tickets off;
    
        add_header Strict-Transport-Security "max-age=63072000" always;
    }

    Notes on these settings:

    • ssl_prefer_server_ciphers off lets the client choose, as TLSRef recommends. It is also the Nginx default.
    • Nginx documents ssl_session_tickets as on by default. Turning it off avoids ticket-key management. If you keep tickets, RFC 9325 requires regular key rotation, for example weekly.
    • Leave ssl_early_data off unless you accept replay risk. See our article on Nginx CVE-2026-132779 and ssl_early_data.
    • Leave ssl_ecdh_curve at auto. OpenSSL 3.5 documents X25519MLKEM768, a hybrid post-quantum group, in its default list.

    How Do You Configure TLS in Apache HTTP Server?

    Use mod_ssl directives with an explicit protocol list. The cipher list is the same TLSRef Intermediate set. Apache lets you set TLS 1.3 suites with the TLSv1.3 protocol specifier on OpenSSL 1.1.1 or later.

    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:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305
    SSLHonorCipherOrder off
    SSLSessionTickets off
    
    <IfModule mod_headers.c>
        Header always set Strict-Transport-Security "max-age=63072000"
    </IfModule>

    The Apache documentation warns that session tickets, which are on by default, compromise perfect forward secrecy unless the server restarts regularly, for example daily. Disabling them is the simpler option. If you run Apache, keep the server current with our Apache HTTP Server 2.4.71 security update guide.

    How Do You Roll Out HSTS Safely?

    Start with a short max-age, confirm that every subdomain serves HTTPS, then raise it in stages. TLSRef recommends two years in its final profile, but a wrong HSTS header can lock users out of a broken site. Our HTTP security headers guide describes the staged plan and the preload requirements. RFC 6797 defines the header.

    How Can You Check Whether Your TLS Configuration Is Correct?

    Test from a machine outside your network and compare the result with the table above. Run these checks only against servers you own.

    # Negotiated protocol and certificate dates
    openssl s_client -connect example.com:443 -servername example.com -brief </dev/null
    openssl s_client -connect example.com:443 -servername example.com </dev/null 2>/dev/null | openssl x509 -noout -subject -issuer -dates
    
    # TLS 1.2 should work; an old protocol should fail
    curl -sSI --tlsv1.2 --tls-max 1.2 https://example.com/ | head -n 1
    openssl s_client -connect example.com:443 -servername example.com -tls1_1 </dev/null

    The last command can also fail because your local OpenSSL refuses TLS 1.1, so treat it as a hint. For a full report, use the open-source testssl.sh (latest release v3.2.5 on November 4, 2026) or the Nmap ssl-enum-ciphers script. Both are linked in the references.

    Why Does Automated Certificate Renewal Matter Now?

    It matters because certificate lifetimes are shrinking on a fixed schedule. The CA/Browser Forum Baseline Requirements limit subscriber certificates to 200 days for those issued from March 15, 2026. The limit becomes 100 days on March 15, 2027 and 47 days on March 15, 2029.

    Maximum TLS certificate validity under the CA/Browser Forum Baseline Requirements: 398, 200, 100 and 47 days
    Maximum validity of publicly trusted TLS certificates by issue date, from the CA/Browser Forum Baseline Requirements (checked November 30, 2026).

    Let’s Encrypt is moving faster than the minimum. Its published plan schedules:

    • May 13, 2026: the opt-in tlsserver profile switches to 45-day certificates.
    • February 10, 2027: the default classic profile switches to 64-day certificates.
    • February 16, 2028: the classic profile moves to 45-day certificates.

    Let’s Encrypt advises ACME clients to use ACME Renewal Information (ARI, RFC 9773) or renew at about two thirds of the certificate lifetime. A fixed 60-day renewal interval will no longer be enough. Also add monitoring that alerts when a certificate is close to expiry.

    Let’s Encrypt also announced the end of OCSP: its timeline turned off the OCSP responders on August 6, 2025, and dropped OCSP URLs from certificates on May 7, 2025. TLSRef’s JSON still lists OCSP stapling as enabled. In practice, ssl_stapling in Nginx and SSLUseStapling in Apache (both off by default) only help if your CA still publishes OCSP. Check with your CA before you enable them.

    What Is Changing in TLS Standards?

    Standards are moving towards TLS 1.3. The IETF published RFC 9846 in July 2026. It obsoletes RFC 8446 (TLS 1.3) and RFC 5246 (TLS 1.2) and sets new requirements for TLS 1.2 implementations.

    On November 19, 2026, NIST added a planning note to SP 800-52 Rev. 2. It says the next revision will recommend that servers “may” support TLS 1.2, instead of “should”, and will not generally allow TLS 1.0 or 1.1. NIST will publish a draft SP 800-52r3 for public comment. Until then, Rev. 2 remains the current publication. If you serve government or regulated customers, watch that draft.

    Additional TLS Security Recommendations

    • Prefer ECDSA P-256 certificates, as TLSRef recommends, or RSA 2048 if you need broad compatibility.
    • Keep OpenSSL and your web server patched. See our Nginx security update article for a recent example.
    • Redirect HTTP to HTTPS, then add HSTS. Keep private keys readable by root only.
    • Do not re-enable DHE-RSA ciphers. TLSRef removed them from Intermediate because they cost more CPU and are more exposed to resource exhaustion, such as the D(HE)at attack (CVE-2002-20001).
    • Re-check after every OpenSSL, Nginx or Apache upgrade.

    FAQ

    What is the best TLS configuration for Nginx and Apache?

    Use TLS 1.2 and 1.3, the six ECDHE cipher suites from TLSRef’s Intermediate profile, a 90-day automated certificate and HSTS. The Nginx and Apache blocks above implement this.

    Is TLS 1.2 still secure in 2026?

    Yes, when configured with forward-secret AEAD ciphers. RFC 9325 still requires TLS 1.2 support. The direction is TLS 1.3, and NIST plans to make TLS 1.2 optional in its next revision.

    Should I disable TLS 1.2 and use TLS 1.3 only?

    Only if all your clients support TLS 1.3. TLSRef’s Modern profile does that, with Firefox 63, Chrome 70 or newer clients. Most public sites keep TLS 1.2.

    Do I need OCSP stapling?

    Not necessarily. Let’s Encrypt ended OCSP, so stapling is of little use for its certificates. Enable stapling only if your CA still provides an OCSP responder.

    How often should I renew TLS certificates?

    Automate renewal at about two thirds of the certificate lifetime, or use ARI. With 200-day certificates today and 47-day certificates by 2029, manual renewal will not scale.

    References

    Related Articles

    Last Verified: November 30, 2026. Facts come from the sources above. Check your own OpenSSL, Nginx and Apache versions before you apply the settings.

  • Synchronous vs Asynchronous Encryption in Simple Words

    Synchronous vs Asynchronous Encryption in Simple Words

    synchronous vs asynchronous encryption

    Encryption keeps our data safe. In simple terms, there are two big families: methods where both sides share the same secret, and methods where each side has different keys. People often call these synchronous and asynchronous encryption, but the more common names are symmetric and asymmetric encryption. This guide explains both in plain English, with short code examples and practical tips.

    Synchronous vs Asynchronous Encryption Explained

    When people say synchronous encryption in everyday security talk, they usually mean symmetric encryption: the sender and the receiver use the same secret key to lock and unlock data. Think of it like a safe with one combination that both of you know. This is the powerhouse used to protect most data in motion and at rest because it is fast and efficient.

    Asynchronous encryption is the common term for asymmetric encryption: there are two different keys, a public key and a private key. The public key is like a lock you can share with the world, and the private key is the only key that opens it. Anyone can lock a message for you using your public key, but only you can open it with your private key.

    Why does the naming cause confusion? In programming, synchronous vs asynchronous usually describes timing and waiting, not cryptography. But in security writing, some folks casually use synchronous to mean “same key on both sides” and asynchronous to mean “different keys on each side.” In this article, synchronous = symmetric (shared key) and asynchronous = asymmetric (public/private key).

    Real-world use mixes both. Your Wi‑Fi with WPA2 or WPA3 mainly uses symmetric encryption (like AES) to keep traffic fast and secure. When you visit an HTTPS site, your browser first uses asymmetric crypto to safely agree on a shared secret, and then switches to symmetric crypto for the actual data transfer. This combo is called hybrid encryption and is the standard on the internet.

    Speed is the big practical difference. Symmetric encryption is very fast and good for large files or streaming. Asymmetric encryption is slower and better for small things like exchanging keys, verifying identity, and digital signatures. That’s why protocols rarely encrypt entire videos with RSA; they use RSA or Elliptic Curve to set up a safe session, then use AES or ChaCha20 for the heavy lifting.

    A good mental model: asymmetric is for trust and handshake, symmetric is for performance. Use asymmetric to agree on secrets without meeting in person, and symmetric to actually protect the bulk of your data once you share a key.

    Public Key vs Shared Key: What These Terms Mean

    A shared key (symmetric key) is a single secret that both sender and receiver know. If you both keep it safe, you can encrypt and decrypt messages quickly. The tough part is how to share that key securely in the first place. If someone steals it, they can read and forge messages.

    A public key system (asymmetric) gives you a key pair. Your public key is safe to share; your private key must stay secret. If I encrypt with your public key, only your private key can decrypt. If I verify your digital signature, I use your public key to check that only your private key could have created it.

    Key exchange is the art of creating a shared key without anyone else learning it. Modern connections often use Diffie-Hellman or Elliptic Curve Diffie-Hellman so both sides derive the same secret over an insecure network. Certificates and certificate authorities help you trust that the public key you see actually belongs to the website or service you intended, blocking simple man-in-the-middle attacks.

    Digital signatures solve a different but related problem: authenticity and integrity. With signatures, you don’t hide the message; you prove who sent it and that it wasn’t changed. The sender signs with their private key; anyone can verify with their public key. That’s how software updates and package managers prove that files are legit.

    Algorithms you will hear a lot: AES and ChaCha20 for symmetric encryption; RSA and Elliptic Curve (like Curve25519, P-256) for asymmetric crypto; SHA-256 and SHA-3 for hashing; GCM and Poly1305 for authenticated encryption. Key sizes matter too: AES-256 is very strong; for RSA, 2048-bit is the common minimum today, with 3072 or 4096 used in higher-assurance systems; for elliptic curve, 256-bit curves like P-256 or X25519 give strong security with small keys.

    Common myths: asymmetric isn’t “better” than symmetric; it does different jobs. Another myth is that bigger keys always mean better security for everything—bigger RSA keys can be slower and increase message size, and not all algorithms scale the same way. Pick modern, vetted algorithms and follow best practices instead of chasing extreme sizes.

    Plain Examples and Simple Code Snippets for Beginners

    Let’s start with a simple symmetric example using AES-GCM in Python. AES-GCM is fast and provides authenticated encryption, meaning it both hides your data and detects tampering. This is great for most app use cases like tokens, small files, or API secrets.

    # Python 3.x
    # pip install cryptography
    from cryptography.hazmat.primitives.ciphers.aead import AESGCM
    import os
    
    key = AESGCM.generate_key(bit_length=256)  # 32 bytes
    aesgcm = AESGCM(key)
    nonce = os.urandom(12)  # 12-byte nonce for GCM
    plaintext = b"hello symmetric world"
    ciphertext = aesgcm.encrypt(nonce, plaintext, associated_data=None)
    
    # Decrypt
    decrypted = AESGCM(key).decrypt(nonce, ciphertext, associated_data=None)
    print(decrypted)  # b'hello symmetric world'

    Here’s the same idea in Node.js using AES-256-GCM. Note how we keep the key and IV (nonce) safe and store the auth tag alongside the ciphertext. You must never reuse the same nonce with the same key in GCM.

    // Node.js
    const crypto = require('crypto');
    
    const key = crypto.randomBytes(32);     // 256-bit key
    const iv = crypto.randomBytes(12);      // 96-bit IV for GCM
    const plaintext = Buffer.from('hello symmetric world');
    
    const cipher = crypto.createCipheriv('aes-256-gcm', key, iv);
    const encrypted = Buffer.concat([cipher.update(plaintext), cipher.final()]);
    const tag = cipher.getAuthTag();
    
    // Decrypt
    const decipher = crypto.createDecipheriv('aes-256-gcm', key, iv);
    decipher.setAuthTag(tag);
    const decrypted = Buffer.concat([decipher.update(encrypted), decipher.final()]);
    console.log(decrypted.toString()); // hello symmetric world

    Now an asymmetric example in Python with RSA-OAEP. We generate a key pair, encrypt with the public key, and decrypt with the private key. In real apps, you’d store keys safely and avoid re-generating them every time.

    # Python 3.x
    # pip install cryptography
    from cryptography.hazmat.primitives.asymmetric import rsa, padding
    from cryptography.hazmat.primitives import hashes
    
    private_key = rsa.generate_private_key(public_exponent=65537, key_size=2048)
    public_key = private_key.public_key()
    
    message = b"hello asymmetric world"
    ciphertext = public_key.encrypt(
        message,
        padding.OAEP(mgf=padding.MGF1(algorithm=hashes.SHA256()),
                     algorithm=hashes.SHA256(),
                     label=None)
    )
    
    plaintext = private_key.decrypt(
        ciphertext,
        padding.OAEP(mgf=padding.MGF1(algorithm=hashes.SHA256()),
                     algorithm=hashes.SHA256(),
                     label=None)
    )
    print(plaintext)  # b'hello asymmetric world'

    And the same idea in Node.js with RSA-OAEP. Again, asymmetric crypto is slower and better used for small messages like keys or short secrets.

    // Node.js
    const { generateKeyPairSync, publicEncrypt, privateDecrypt } = require('crypto');
    
    const { publicKey, privateKey } = generateKeyPairSync('rsa', { modulusLength: 2048 });
    
    const msg = Buffer.from('hello asymmetric world');
    const enc = publicEncrypt({ key: publicKey, oaepHash: 'sha256' }, msg);
    const dec = privateDecrypt({ key: privateKey, oaepHash: 'sha256' }, enc);
    
    console.log(dec.toString()); // hello asymmetric world

    Practical tips: never roll your own crypto; use high-level, audited libraries. Prefer authenticated encryption modes like AES-GCM or ChaCha20-Poly1305. For new systems, consider elliptic curves (X25519/XChaCha20) for speed and strong security. Always use a secure random number generator for keys and nonces. Rotate keys and store them with a proper key management system.

    Choosing the Right Method: Speed, Size, Security

    Speed: symmetric encryption wins by a mile. AES and ChaCha20 can encrypt gigabytes per second on modern hardware, sometimes with CPU instruction support. Asymmetric methods like RSA and ECDH are thousands to millions of times slower per byte, which is why we only use them for small payloads such as keys or identity operations.

    Size: asymmetric ciphertexts and signatures are larger. For RSA-2048, the ciphertext size is roughly the key size (around 256 bytes) even for a tiny message. Symmetric ciphertexts add a small overhead (nonce + tag, often a few dozen bytes) no matter the message size. If you care about bandwidth or storage, symmetric is more compact for bulk data.

    Security properties: asymmetric gives you identity tools like digital signatures and safe key exchange over the public internet. Symmetric gives you efficient confidentiality and integrity once you already share a secret. For modern protocols, add forward secrecy using ephemeral Diffie-Hellman (X25519 or P-256): if a server’s long-term key is later stolen, past traffic stays safe.

    Typical pattern: hybrid encryption. Use asymmetric crypto to authenticate and agree on a fresh symmetric session key (the TLS handshake), then use symmetric crypto to protect the rest of the traffic. For files, encrypt the file with a random symmetric key, then encrypt that key with the recipient’s public key and attach it.

    A simple decision guide: if you need to encrypt large data fast (files, streams, databases), choose symmetric (AES-GCM or ChaCha20-Poly1305) and manage keys well. If you need to send a secret to someone you don’t share a key with, or you need verifiable identity, use asymmetric to exchange or wrap the symmetric key. For offline backups you control, symmetric with a strong passphrase-based key derivation (Argon2, scrypt) is a good fit.

    Quick Q&A:
    Q: Is asymmetric always more secure? A: No, it solves different problems; both are strong when used correctly.
    Q: Can I encrypt big files with RSA? A: Don’t. Use RSA/ECC to encrypt a random symmetric key, then use AES/ChaCha20 for the file.
    Q: What’s best for mobile? A: ChaCha20-Poly1305 is fast on devices without AES hardware; AES-GCM is great where hardware support exists.
    Q: What about passwords? A: Never encrypt passwords; hash them with a slow, salted KDF like Argon2, bcrypt, or scrypt.

    In short, synchronous (symmetric) encryption is your fast workhorse for protecting data, and asynchronous (asymmetric) encryption is your smart doorman for identity, key exchange, and signatures. Most real systems use both in a hybrid design: public key methods to agree on secrets, shared key methods to move data at high speed. Use modern, vetted algorithms, authenticated modes, secure randomness, and proper key management to stay safe without overcomplicating your stack.

    Related reading