Chapter 3. Configuring TLS encryption on an Apache HTTP server
By default, Apache distributes content to clients by using an unsecured HTTP connection. To secure web traffic, you can enable TLS encryption and configure often used encryption-related settings on an Apache HTTP Server.
3.1. Adding TLS encryption to an Apache HTTP server Copy linkLink copied to clipboard!
You can secure web traffic by installing mod_ssl. Configure the virtual host to use the IdM-issued private key and certificate to enable encrypted HTTPS connections for the domain by using the sub-CA credentials.
Prerequisites
- The Apache HTTP Server is installed and running.
The private key is stored in the
/etc/pki/tls/private/example.com.keyfile.For details about creating a private key and certificate signing request (CSR), and how to request a certificate from a certificate authority (CA), see documentation of your CA.
-
The TLS certificate is stored in the
/etc/pki/tls/certs/example.com.crtfile. If you use a different path, follow the corresponding steps of the procedure. -
The CA certificate is stored in the
/etc/pki/tls/certs/ca.crtfile. If you use a different path, follow the corresponding steps of the procedure. - The clients and the web server resolve the hostname of the server to the IP address of the web server.
-
If the server runs Red Hat Enterprise Linux 10 (RHEL) and the Federal Information Processing Standards (FIPS) mode is enabled, clients must either support the
Extended Master Secret(EMS) extension or use Transport Layer Security (TLS) 1.3. TLS 1.2 connections without EMS fail. For details, see the Red Hat Knowledgebase solution TLS extension "Extended Master Secret" enforced.
Procedure
Install the
mod_sslpackage:dnf install mod_ssl
# dnf install mod_sslCopy to Clipboard Copied! Toggle word wrap Toggle overflow Edit the
/etc/httpd/conf.d/ssl.conffile and add the following settings to the<VirtualHost _default_:443>directive:Set the server name:
ServerName example.com
ServerName example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow The server name must match the entry set in the
Common Namefield of the certificate.Optional: If the certificate includes additional host names in the
Subject Alt Names(SAN) field, you can configuremod_sslto provide TLS encryption also for these host names. To configure this, add theServerAliasesparameter with corresponding names:ServerAlias www.example.com server.example.com
ServerAlias www.example.com server.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow Set the paths to the private key, the server certificate, and the CA certificate:
SSLCertificateKeyFile "/etc/pki/tls/private/example.com.key" SSLCertificateFile "/etc/pki/tls/certs/example.com.crt" SSLCACertificateFile "/etc/pki/tls/certs/ca.crt"
SSLCertificateKeyFile "/etc/pki/tls/private/example.com.key" SSLCertificateFile "/etc/pki/tls/certs/example.com.crt" SSLCACertificateFile "/etc/pki/tls/certs/ca.crt"Copy to Clipboard Copied! Toggle word wrap Toggle overflow
For security reasons, configure that only the
rootuser can access the private key file:chown root:root /etc/pki/tls/private/example.com.key
# chown root:root /etc/pki/tls/private/example.com.keyCopy to Clipboard Copied! Toggle word wrap Toggle overflow chmod 600 /etc/pki/tls/private/example.com.key
# chmod 600 /etc/pki/tls/private/example.com.keyCopy to Clipboard Copied! Toggle word wrap Toggle overflow WarningIf unauthorized users access the private key, revoke the certificate, create a new private key, and request a new certificate. Otherwise, the TLS connection is no longer secure.
-
Open a web browser and connect to
https://example.com.
-
Open a web browser and connect to
3.2. Setting the supported TLS protocol versions on an Apache HTTP server Copy linkLink copied to clipboard!
By default, the Apache HTTP Server on RHEL uses the system-wide cryptographic policy that defines safe default values, which are also compatible with recent browsers. For example, the DEFAULT policy defines that only the TLSv1.2 and TLSv1.3 protocol versions are enabled in Apache HTTP Server.
You can manually configure TLS protocol versions that the Apache HTTP Server supports. You need to enable only specific TLS protocol versions in your environment in these cases:
-
If your environment requires that clients can also use the weak
TLS1(TLSv1.0) orTLS1.1protocol. -
If you want to configure that Apache only supports the
TLSv1.2orTLSv1.3protocol.
Prerequisites
- You have enabled transport layer security (TLS) encryption on the server.
-
If the server runs Red Hat Enterprise Linux 10 (RHEL) and the Federal Information Processing Standards (FIPS) mode is enabled, clients must either support the
Extended Master Secret(EMS) extension or use Transport Layer Security (TLS) 1.3. TLS 1.2 connections without EMS fail. For details, see the Red Hat Knowledgebase solution TLS extension "Extended Master Secret" enforced.
Procedure
Edit the
/etc/httpd/conf/httpd.conffile and add the<VirtualHost>directive for which you want to set theTLSv1.3protocol version:SSLProtocol -All TLSv1.3
SSLProtocol -All TLSv1.3Copy to Clipboard Copied! Toggle word wrap Toggle overflow Restart the
httpdservice:systemctl restart httpd
# systemctl restart httpdCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Verify support for
TLSv1.3:openssl s_client -connect example.com:443 -tls1_3
# openssl s_client -connect example.com:443 -tls1_3Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify support for
TLSv1.2:openssl s_client -connect example.com:443 -tls1_2
# openssl s_client -connect example.com:443 -tls1_2Copy to Clipboard Copied! Toggle word wrap Toggle overflow If the server does not support the protocol, the command returns an error:
140111600609088:error:1409442E:SSL routines:ssl3_read_bytes:tlsv1 alert protocol version:ssl/record/rec_layer_s3.c:1543:SSL alert number 70
140111600609088:error:1409442E:SSL routines:ssl3_read_bytes:tlsv1 alert protocol version:ssl/record/rec_layer_s3.c:1543:SSL alert number 70Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Optional: Repeat the command for other TLS protocol versions.
3.3. Setting the supported ciphers on an Apache HTTP server Copy linkLink copied to clipboard!
By default, the Apache HTTP Server uses the system-wide cryptographic policy that defines safe default values, which are also compatible with recent browsers. For the list of ciphers the system-wide cryptographic policy allows, see the /etc/crypto-policies/back-ends/openssl.config file.
You can manually configure ciphers that the Apache HTTP Server supports.
Prerequisites
- You have enabled Transport Layer Security (TLS) encryption on the server.
Procedure
Install the
nmappackage:dnf install nmap
# dnf install nmapCopy to Clipboard Copied! Toggle word wrap Toggle overflow Edit the
/etc/httpd/conf/httpd.conffile and add theSSLCipherSuiteparameter to the<VirtualHost>directive for which you want to set the TLS ciphers:SSLCipherSuite "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH:!SHA1:!SHA256"
SSLCipherSuite "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH:!SHA1:!SHA256"Copy to Clipboard Copied! Toggle word wrap Toggle overflow This example enables only the
EECDH+AESGCM,EDH+AESGCM,AES256+EECDH, andAES256+EDHciphers and disables all ciphers that use theSHA1andSHA256message authentication code (MAC).Restart the
httpdservice:systemctl restart httpd
# systemctl restart httpdCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Display the supported ciphers:
nmap --script ssl-enum-ciphers -p 443 example.com
# nmap --script ssl-enum-ciphers -p 443 example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow