Configure Apache HTTP Server
To configure the Apache HTTP Server, you need to perform the following tasks:
- Set FXPKCS11 environment variables.
- Create a key pair on the with pkcs11-tool.
- Generate a Certificate Signing Request (CSR) by using the Apache Server private key.
- Create a self-signed root certificate authority (CA).
- Sign the Apache Server CSR.
- Configure Apache to use the signed certificate and the private key stored on the .
- (Optional) Create a client certificate for the browser that connects to Apache HTTP Server.
- Confirm that Apache uses the new TLS Certificate and private key (stored on the ) for HTTPS connections.
The following sections provide the steps to perform these tasks.
In a terminal, run the following sequence of commands to set the required FXPKCS11 environment variables:
Be sure to modify the file path to match the location where the libfxpkcs11.so and fxpkcs11.cfg files are stored on your system.
In a terminal, run the following command to create a new key pair on the with pkcs11-tool:
Currently, Apache has a bug that prevents RSA certificates from being served correctly to the browser. This bug might be fixed, but we recommend that you create and use an ECC certificate, as demonstrated in the code example.
Enter the password of the identity configured in fxpkcs11.cfg when prompted for your PIN.
If the command succeeds, the output includes the keys, as shown in the following output sample:
One private ECC 256-bit key was created with asymmetric-sign usage, and one public ECC 256-bit key was created with verify usage.
Before completing the steps in this section, create a directory to store the TLS certificates that will be created, and go to that directory. Then, perform the following process to create a CSR:
In a terminal, run the following command to generate a CSR using the private key that you created on the for Apache Server:
The common name for the Apache server certificate should match the domain name of the virtual host that uses it.
We use a self-signed root CA in this section for demonstration purposes. In a production environment, you should use a secure certificate authority (such as the ) for all private key generation and certificate signing operations.
Perform the following process to create a CA:
In a terminal, run the following sequence of commands to generate a root private key and self-signed certificate. This certificate signs the Apache Server certificate in the next section.
In a terminal, run the following command to issue a signed Apache Server certificate by using the self-signed root CA created in the previous step:
This section shows how to modify the configuration file for a virtual host that runs in Apache. Configuring a virtual host is outside of the scope of this guide. Refer to this documentation specific to your operating system if you have not already configured a virtual host.
In a text editor, open the configuration file for the virtual host for which you want to configure HTTPS. The location of the configuration file is specific to your system. Modify the file as shown in the following example:
You must modify the location of the signed Apache certificate specified in the SSLCertificateFiledefine according to where it is stored on your system.
You must modify the object name of the Apache private key specified in the SSLCertificateKeyFile define so it matches the label set in the pkcs11-tool command.
Restart Apache to save and apply the configuration.
Complete this step only if you want to use mutual authentication.
In a terminal, generate a client keypair by using the following command:
Run the following command to create a client certificate signing request:
Run the following command to sign the CSR with the CA certificate created earlier in this section:
Run the following command to convert the signed client certificate to PKCS #12 format for insertion into the browser:
8 | Confirm that Apache uses the new TLS certificate and private key (stored on the Vectera Plus) for HTTPS connections
If you did not create a client certificate for mutual authentication in the previous section, start at step 4 of the following procedure.
The following steps assume you are using a Firefox web browser. Some actions might have different results when using other browsers, but the overall experience is the same.
In Firefox, go to Settings > Privacy & Security > Certificates and then select [ View Certificates ].
On the Your Certificates tab, select [ Import ] to import the client certificate that was converted to PKCS #12 (such as ssl-client-pkcs12.p12).
On the Authorities tab, select [ Import ] to import the CA certificate (such as ssl-ca-cert.pem).
Go to the IP address from which Apache is running over HTTPS.
If you configured a client certificate in the browser for mutual authentication, you should see a lock icon next to the web address. If you did not configure a client certificate, bypass the warning that displays and connect to the website anyway.
View the certificate that the website served to the browser and confirm that it is the certificate configured in Apache.