4. mTLS in Apache HTTPD using a Self-Signed CA and Client Certificates
Creating a Self-Signed CA and Client Certificate Using Keystore Explorer (PKCS#12) for mTLS in Apache HTTPD
Overview
Section titled “Overview”This optional example adds client certificate authentication to the Fortified ID Access route /access/authn/cert. Clients still verify Apache’s server certificate from step 2. For this route, Apache also verifies the client certificate against a CA you configure.
Use the self-signed CA below for a test setup. For your deployment, choose the client CA, certificate lifetimes, and trust policy that fit your environment. Keep the CA private key separate from the Apache server and give each test client only its own client key pair.
Prerequisites
Section titled “Prerequisites”- Keystore Explorer installed.
- Working HTTPS and a verified Access route from step 3.
mod_sslandmod_headersenabled in Apache. The example usesmod_headersto pass certificate information to Access.
Step 1: Create a Self-Signed CA Certificate
Section titled “Step 1: Create a Self-Signed CA Certificate”- Open Keystore Explorer and create a new keystore (
PKCS#12format). - Click Tools → Generate Key Pair.
- Select RSA (2048-bit or higher) and click OK.
- Enter the Distinguished Name (DN) details (e.g.,
CN=MyCA, O=MyOrg, C=SE). - Set the validity period (e.g., 3650 days for 10 years). Press Apply to update the years.
- Click Add Extensions
- Click Use Standard Template
- Select CA and click OK
- Click OK.
- Click OK.
- Keep or change the Alias. Click OK
- Set a password for the key pair and click OK.
- Click OK.
- Save the keystore (
myCA.p12). - Set a password for the keystore and click OK.
Step 2: Export the CA Certificate
Section titled “Step 2: Export the CA Certificate”- Open
myCA.p12in Keystore Explorer. - Right-click the CA key pair → Export → Export Certificate Chain.
- Choose Head Only, X.509 and PEM format and save it as
ca.cer.
Step 3: Create a Client Certificate
Section titled “Step 3: Create a Client Certificate”- Open
myCA.p12in Keystore Explorer. - Right-click the CA key pair → Sign
- Select Sign new key pair, select (2048-bit or higher) and click OK.
- Set the validity period (e.g., 3650 days for 10 years). Press Apply to update the years.
- Enter the Distinguished Name (DN) details (e.g.,
CN=Client, O=MyOrg, C=SE). - Click Add Extensions
- Click Use Standard Template
- Select SSL Client and click OK
- Click OK
- Click OK.
- Keep or change the Alias. Click OK
- Set a password for the key pair and click OK.
- Right-click the Client key pair → Export → Export Key Pair.
- Select PKCS#12, set a password for the key pair and the path for the Export File.
- Click Export.
- Save the keystore if you would like to keep the client certificate in the keystore.
Step 4: Configure Apache HTTPD for mTLS on /access/authn/cert
Section titled “Step 4: Configure Apache HTTPD for mTLS on /access/authn/cert”Copy the exported public CA certificate, ca.cer, to C:\Apache24\conf. Use your actual installation path if it differs.
-
Open
C:\Apache24\conf\extra\httpd-ssl.confand locate the HTTPS virtual host that serves Access. -
Add the CA trust directive and the route configuration inside that virtual host. This example uses TLS 1.2 for the client-facing connection so Apache can request a client certificate on the selected route. The protocol setting applies to the whole virtual host. Check that this scope and protocol fit your deployment before applying it.
SSLCACertificateFile "${SRVROOT}/conf/ca.cer"SSLProtocol -all +TLSv1.2Set the certificate headers from the TLS connection. Use the example only for the Access route that expects them.
<Location "/access/authn/cert">SSLVerifyClient requireSSLVerifyDepth 10RequestHeader set SSL_CLIENT_CERT "%{SSL_CLIENT_CERT}s"RequestHeader set SSL_CLIENT_VERIFY "%{SSL_CLIENT_VERIFY}s"RequestHeader add X-Forwarded-Scheme https</Location> -
From
C:\Apache24\bin, test the Windows service configuration in PowerShell. Substitute your service name if needed.Terminal window .\httpd.exe -n "Apache HTTP Server" -t -
Restart the service after the test reports
Syntax OK.
Step 5: Import the client keystore and verify access
Section titled “Step 5: Import the client keystore and verify access”- Import the exported client PKCS#12 file into the certificate store your browser or test client uses.
- Open the configured Access certificate route and confirm that authentication succeeds with the trusted client certificate.
- Repeat the request without a client certificate and with an untrusted client certificate. Confirm that both requests are rejected.
- Verify that normal Access routes still work without requesting a client certificate.