| |

LFCE 101 ๐Ÿง TLS โ€” Concepts

โฑ๏ธ Estimated read: 13 min | |

TLS (Transport Layer Security) is the cryptographic protocol that sits between the transport layer and the application layer of the TCP/IP stack, providing confidentiality, integrity, and authentication for the client-server communication . The previous chapters covered the tools that inspect and control the traffic; this chapter covers the protocol that protects the traffic in transit. The LFCE exam expects the candidate to configure the host-based and user-based security for a service , and TLS is the mechanism that secures the HTTP, the SMTP, the LDAP, and the other application protocols.

The protocol is built on a combination of the algorithms: the symmetric encryption for the data confidentiality, the asymmetric encryption and the key exchange for the session key agreement and the authentication, and the hash functions for the message integrity . The combination is called a cipher suite, and the client and the server negotiate the suite during the handshake. The handshake is the sequence that authenticates the server, agrees on the session key, and establishes the secure channel. The certificate is the mechanism that binds the server’s identity to its public key, and the Certificate Authority (CA) is the trusted third party that signs the certificate .

Key point: The TLS handshake authenticates the server by verifying that its certificate is signed by a trusted CA and that the certificate’s Common Name (CN) or Subject Alternative Name (SAN) matches the hostname the client is connecting to . The client and the server negotiate the cipher suite and the TLS version, and the server proves that it possesses the private key corresponding to the public key in the certificate. The session key is then derived from the key exchange, and all subsequent data is encrypted with the symmetric cipher .


Why TLS requires the certificate and the handshake

The authentication problem.

The encryption alone does not prevent the man-in-the-middle attack. An attacker could intercept the connection, present its own certificate, and decrypt the traffic if the client does not verify the certificate. The certificate is the mechanism that binds the server’s public key to its identity, and the CA signature is the mechanism that the client uses to verify that the certificate is authentic . The client must have the CA’s public key in its trust store, and it must verify that the certificate’s domain matches the hostname it is connecting to. A certificate issued for a different domain is invalid, even if it is signed by a trusted CA .

The key-exchange problem.

The symmetric encryption is fast, but it requires both parties to share the same key. The asymmetric encryption is slow, but it allows the parties to agree on the shared key without ever transmitting it. The TLS handshake uses the asymmetric encryption (or the Diffie-Hellman key agreement) to establish the session key, and then it switches to the symmetric encryption for the data . The key exchange is the mechanism that solves the key-distribution problem, and the session key is the mechanism that makes the bulk encryption practical.

The version problem.

The TLS 1.2 and the TLS 1.3 have the different handshake flows and the different security properties. The TLS 1.3 removes the static RSA and the static Diffie-Hellman cipher suites, which ensures that all the public-key-based key exchange provides the forward secrecy . The TLS 1.3 encrypts all the handshake messages after the ServerHello, and it reduces the number of the round trips . The version is the variable that determines the security and the performance, and the server should be configured to prefer the TLS 1.3 and to allow the TLS 1.2 only for the legacy clients.


a. The certificate and the PKI

The certificate is an X.509 document that contains the server’s public key, the identity information, the validity period, and the CA’s signature . The CA is the trusted third party that signs the certificate, and the client trusts the CA by having its certificate in the trust store.

# View the certificate content
openssl x509 -in server.crt -text -noout

# Check the certificate's subject and the issuer
openssl x509 -in server.crt -noout -subject -issuer

# Check the validity period
openssl x509 -in server.crt -noout -dates

The openssl x509 -text command prints the full certificate content, including the subject, the issuer, the validity, the public key, and the extensions . The -subject and -issuer options show the identity of the certificate’s owner and the CA that signed it. The -dates option shows the notBefore and notAfter dates, which the client checks against its own clock .

The certificate chain is the sequence from the server’s certificate to the trusted root CA. The server should send the full chain, including the intermediate certificates, so that the client can build the path to the root that it trusts .

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

The openssl s_client -showcerts command connects to the server and prints the certificate chain that the server sends . The chain must include the server’s certificate and the intermediate CA’s certificate. The root CA’s certificate is not sent, because the client already has it in the trust store.


b. The handshake and the cipher suite

The handshake is the sequence of the messages that authenticate the server and establish the session key. The TLS 1.2 and the TLS 1.3 have the different flows, but the principles are the same.

# Test the TLS handshake with the openssl s_client
openssl s_client -connect example.com:443 -tls1_3

# Check the negotiated protocol and the cipher
openssl s_client -connect example.com:443 | grep -E "Protocol|Cipher"

The openssl s_client -tls1_3 command forces the TLS 1.3 handshake, which is the mechanism for the version-specific testing . The grep on the output shows the negotiated protocol and the cipher suite, which are the result of the negotiation.

The cipher suite is the combination of the algorithms: the key exchange, the authentication, the bulk encryption, and the hash . The TLS 1.3 cipher suites are the AEAD (Authenticated Encryption with Associated Data) algorithms, such as the TLS_AES_256_GCM_SHA384 and the TLS_CHACHA20_POLY1305_SHA256 . The TLS 1.2 cipher suites include the key exchange and the authentication, such as the TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 . The server’s cipher list determines which suites it accepts, and the client’s list determines which it offers. The server selects the suite that both support.


c. The TLS 1.3 improvements

The TLS 1.3 is the current version, and it addresses the known weaknesses of the TLS 1.2. The handshake is shorter, the cipher suites are stronger, and the forward secrecy is mandatory .

# Check the TLS version that the server supports
openssl s_client -connect example.com:443 -tls1_2
openssl s_client -connect example.com:443 -tls1_3

The -tls1_2 and the -tls1_3 options test the specific versions, which is the mechanism for the version-support check . A server that supports the TLS 1.3 and the TLS 1.2 should negotiate the 1.3 when the client offers both, because the server prefers the higher version.

The TLS 1.3 handshake has the one round-trip (1-RTT) for the full handshake and the zero round-trip (0-RTT) for the resumption, compared to the two round-trips of the TLS 1.2 . The 0-RTT is the mechanism that allows the client to send the application data in the first flight, at the cost of the replay protection . The TLS 1.3 also removes the data compression, which eliminates the CRIME-style attacks .


Complete Example Session

# ============================================
# PART 1: CHECK THE CERTIFICATE
# ============================================
openssl x509 -in server.crt -text -noout
# Output shows the subject, issuer, validity, and public key

# ============================================
# PART 2: CHECK THE SUBJECT AND ISSUER
# ============================================
openssl x509 -in server.crt -noout -subject -issuer
# Output shows the certificate's owner and the CA

# ============================================
# PART 3: CHECK THE VALIDITY
# ============================================
openssl x509 -in server.crt -noout -dates
# Output shows the notBefore and notAfter

# ============================================
# PART 4: CHECK THE CHAIN
# ============================================
openssl s_client -connect example.com:443 -showcerts
# Output shows the certificate chain

# ============================================
# PART 5: TEST THE TLS 1.3 HANDSHAKE
# ============================================
openssl s_client -connect example.com:443 -tls1_3
# Output shows the TLS 1.3 handshake

# ============================================
# PART 6: TEST THE TLS 1.2 HANDSHAKE
# ============================================
openssl s_client -connect example.com:443 -tls1_2
# Output shows the TLS 1.2 handshake

# ============================================
# PART 7: CHECK THE NEGOTIATED CIPHER
# ============================================
openssl s_client -connect example.com:443 | grep -E "Protocol|Cipher"
# Output shows the protocol and the cipher suite

# ============================================
# PART 8: VERIFY THE DOMAIN MATCH
# ============================================
openssl s_client -connect example.com:443 -servername example.com
# The SNI is sent, and the certificate's domain is checked

# ============================================
# PART 9: CHECK THE EXPIRY
# ============================================
echo | openssl s_client -connect example.com:443 2>/dev/null | openssl x509 -noout -dates
# Output shows the expiry dates

# ============================================
# PART 10: CLEAN UP
# ============================================
# No cleanup needed for the read-only checks

The ten parts demonstrate the TLS inspection: the certificate content, the subject and issuer, the validity, the chain, the TLS 1.3 handshake, the TLS 1.2 handshake, the negotiated cipher, the SNI domain check, and the expiry. The critical verification is Part 8: the -servername option sends the SNI (Server Name Indication), which is the mechanism that allows the server to select the correct certificate for the hostname .


Quick Reference

TLS Properties

PropertyMechanism
ConfidentialitySymmetric encryption (AES-GCM, ChaCha20)
IntegrityHash functions (SHA-256, SHA-384)
AuthenticationX.509 certificates, CA signatures
Key exchangeDiffie-Hellman, ECDHE
Forward secrecyECDHE (mandatory in TLS 1.3)

TLS Versions

VersionHandshakeKey Features
TLS 1.22-RTTStatic RSA, weak ciphers allowed
TLS 1.31-RTT (0-RTT resumption)AEAD only, forward secrecy mandatory

Certificate Commands

CommandPurpose
openssl x509 -in cert -text -nooutView the certificate
openssl x509 -in cert -noout -subject -issuerView the subject and issuer
openssl x509 -in cert -noout -datesView the validity
openssl s_client -connect host:443 -showcertsView the chain
openssl s_client -connect host:443 -tls1_3Test the TLS 1.3

Trust Store Locations

DistributionCA Certificate Directory
RHEL / CentOS/etc/pki/tls/certs
Debian / Ubuntu/etc/ssl/certs
Oracle Linux/etc/pki/tls/certs

Best Practices

โœ… Do This:

# Verify the certificate chain
openssl s_client -connect example.com:443 -showcerts          # โœ…

# Check the certificate's domain
openssl x509 -in server.crt -noout -subject                  # โœ…

# Test the TLS 1.3 support
openssl s_client -connect example.com:443 -tls1_3            # โœ…

# Check the expiry
openssl x509 -in server.crt -noout -dates                    # โœ…

# Use the SNI for the hostname-specific certificate
openssl s_client -connect example.com:443 -servername example.com # โœ…

โŒ Don’t Do This:

# Use the self-signed certificate in production
# The clients do not trust it without the CA installation # โŒ

# Ignore the certificate expiry
# The expired certificate fails the handshake             # โŒ

# Use the TLS 1.0 or the TLS 1.1
# They are deprecated and vulnerable                     # โŒ

# Skip the domain match check
# The certificate for the other domain is invalid         # โŒ

# Use the weak cipher suites
# The RC4 and the 3DES are broken                         # โŒ

Common Pitfalls

PitfallWhy It HappensFix
The certificate errorThe CA is not trustedInstall the CA in the trust store
The domain mismatchThe CN/SAN does not matchIssue the certificate for the correct domain
The expired certificateThe validity period passedRenew the certificate
The handshake failureThe cipher or the version mismatchCheck the cipher list and the version
The chain incompleteThe intermediate is missingSend the full chain

Real-World Examples

1. View the certificate

openssl x509 -in server.crt -text -noout

2. Check the subject

openssl x509 -in server.crt -noout -subject

3. Check the issuer

openssl x509 -in server.crt -noout -issuer

4. Check the dates

openssl x509 -in server.crt -noout -dates

5. Check the chain

openssl s_client -connect example.com:443 -showcerts

6. Test the TLS 1.3

openssl s_client -connect example.com:443 -tls1_3

7. Test the TLS 1.2

openssl s_client -connect example.com:443 -tls1_2

8. Check the negotiated cipher

openssl s_client -connect example.com:443 | grep Cipher

9. Check the SNI

openssl s_client -connect example.com:443 -servername example.com

10. Check the expiry

echo | openssl s_client -connect example.com:443 2>/dev/null | openssl x509 -noout -dates

Visual

The TLS Handshake (TLS 1.2 vs 1.3)

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  THE TLS 1.3 HANDSHAKE IS SHORTER                             โ”‚
โ”‚                                                               โ”‚
โ”‚  TLS 1.2 (2-RTT):                                             โ”‚
โ”‚  Client โ”€โ”€ ClientHello โ”€โ”€โ–ถ Server                            โ”‚
โ”‚  Client โ—€โ”€โ”€ ServerHello, Cert, ServerHelloDone โ”€โ”€ Server     โ”‚
โ”‚  Client โ”€โ”€ ClientKeyExchange, ChangeCipherSpec, Finished โ”€โ”€โ–ถ โ”‚
โ”‚  Client โ—€โ”€โ”€ ChangeCipherSpec, Finished โ”€โ”€ Server             โ”‚
โ”‚                                                               โ”‚
โ”‚  TLS 1.3 (1-RTT):                                             โ”‚
โ”‚  Client โ”€โ”€ ClientHello + KeyShare โ”€โ”€โ–ถ Server                 โ”‚
โ”‚  Clientโ—€โ”€โ”€ ServerHello + KeyShare + Cert + Finished โ”€โ”€ Serverโ”‚
โ”‚  Client โ”€โ”€ Finished โ”€โ”€โ–ถ Server                               โ”‚
โ”‚  (all handshake messages after ServerHello are encrypted)     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

The Certificate Chain

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  THE CHAIN OF TRUST                                          โ”‚
โ”‚                                                              โ”‚
โ”‚  Root CA (trusted by the client)                             โ”‚
โ”‚       โ”‚ signs                                                โ”‚
โ”‚       โ–ผ                                                      โ”‚
โ”‚  Intermediate CA                                             โ”‚
โ”‚       โ”‚ signs                                                โ”‚
โ”‚       โ–ผ                                                      โ”‚
โ”‚  Server Certificate (example.com)                            โ”‚
โ”‚                                                              โ”‚
โ”‚  The server sends the leaf and the intermediate.             โ”‚
โ”‚  The client has the root in the trust store.                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

The Cipher Suite

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  THE CIPHER SUITE IS THE COMBINATION OF THE ALGORITHMS       โ”‚
โ”‚                                                              โ”‚
โ”‚  TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384                       โ”‚
โ”‚  โ”œโ”€โ”€ ECDHE: key exchange (forward secrecy)                   โ”‚
โ”‚  โ”œโ”€โ”€ RSA: authentication (the certificate)                   โ”‚
โ”‚  โ”œโ”€โ”€ AES_256_GCM: bulk encryption                            โ”‚
โ”‚  โ””โ”€โ”€ SHA384: hash (integrity)                                โ”‚
โ”‚                                                              โ”‚
โ”‚  TLS 1.3: TLS_AES_256_GCM_SHA384 (AEAD)                      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Summary

ItemValue
ProtocolTLS (Transport Layer Security)
PurposeConfidentiality, integrity, authentication
CertificateX.509, signed by a CA
Trust store/etc/pki/tls/certs, /etc/ssl/certs
HandshakeAuthenticates the server, agrees on the key
TLS 1.31-RTT, AEAD only, forward secrecy mandatory
TLS 1.22-RTT, static RSA allowed
Cipher suiteKey exchange + auth + encryption + hash
Verificationopenssl s_client, openssl x509

Key takeaways:

  • TLS provides the confidentiality, the integrity, and the authentication. The symmetric encryption protects the data, the hash functions ensure the integrity, and the X.509 certificates authenticate the server . The protocol sits between the transport layer and the application layer, and it is the mechanism that secures the HTTP, the SMTP, and the other application protocols.
  • The certificate binds the server’s identity to its public key. The CA signs the certificate, and the client verifies the signature with the CA’s public key in its trust store . The certificate’s Common Name (CN) or Subject Alternative Name (SAN) must match the hostname the client is connecting to.
  • The handshake authenticates the server and establishes the session key. The client and the server negotiate the cipher suite and the TLS version, the server proves its identity with the certificate, and the key exchange derives the session key . The TLS 1.3 handshake is shorter and encrypts the handshake messages after the ServerHello .
  • The TLS 1.3 is the current version. It removes the static RSA and the static Diffie-Hellman, mandates the forward secrecy, and uses the AEAD ciphers . The TLS 1.2 remains for the legacy clients, but it should be configured with the strong ciphers and the ECDHE key exchange.
  • The openssl s_client is the verification tool. The -showcerts option prints the chain, the -tls1_3 and the -tls1_2 options test the versions, and the -servername option sends the SNI . The openssl x509 command views the certificate’s content, the subject, the issuer, and the dates.
  • The trust store is the client’s source of the trusted CAs. The RHEL and the Oracle Linux use the /etc/pki/tls/certs directory, and the Debian and the Ubuntu use the /etc/ssl/certs directory . The CA certificate must be installed in the trust store for the client to trust the server’s certificate.

Remember: TLS is the protocol that secures the application traffic. The certificate is the identity, the CA is the trust anchor, and the handshake is the mechanism that authenticates the server and establishes the session key. The TLS 1.3 is the current version, and the TLS 1.2 is the legacy fallback. The openssl s_client and the openssl x509 are the verification tools, and the trust store is the client’s source of the trusted CAs. The result is the secure channel where the client knows who the server is and the data cannot be read or modified in transit.


Was this helpful?


Stop using slow, ad-bloated tool sites! ๐Ÿคฎ

๐Ÿ”Ž Search “KandZ Tools” on Google to use many professional utilities for free.

KandZ.me is the ultimate minimalist hub for:
โœ… Finance (Mortgage, Interest, Inflation)
โœ… Tech (Base64, JSON, Dev Suite, IP)
โœ… Health (BMI, BMR, TDEE)
โœ… Productivity (Timer, Workspace, QR)

โšก๏ธ Fast & Private
๐Ÿ”’ No data leaves your device
๐Ÿ’Ž 100% Free

๐Ÿ”— Use it now: https://tools.kandz.me
๐Ÿ”– Bookmark itโ€”youโ€™ll need it later!