Difference between revisions of "SSL Certificates For Local Network"
| Line 48: | Line 48: | ||
# Set the <code>SSLCertificateKeyFile</code> option in the <code>VirtualHost</code> definition to be the server's private key file exported in the step above. | # Set the <code>SSLCertificateKeyFile</code> option in the <code>VirtualHost</code> definition to be the server's private key file exported in the step above. | ||
# Restart the httpd service | # Restart the httpd service | ||
| + | |||
| + | ==== On a Unifi Dream Machine firewall/router/switch ==== | ||
| + | |||
| + | # Copy the server's full chain file to <code>/mnt/data/unifi-os/unifi-core/config/unifi-core.crt</code> | ||
| + | # Copy the server's key file to <code>/mnt/data/unifi-os/unifi-core/config/unifi-core.key</code> | ||
| + | # <code>unifi-os restart</code> | ||
==== In the ntopng application on Linux ==== | ==== In the ntopng application on Linux ==== | ||
Revision as of 20:36, 4 February 2021
This page is about creating and installing SSL certificates on servers on my local LAN.
Managing Certificates
I use the XCA tool to manage my certificates.
The first step is to create a certificate database which will contain all of my certicates, File -> New Database. I called it localdomain-ca.xdb.
Create a root certificate for your private "certificate authority"
- Select the
Certificatestab, - Click
New Certificatebutton, - Select the
Sourcetab and select[default] CAunderTemplate for new certificate. Click theApply allbutton, - Select the
Subjecttab and fill in theInternal NameandcommonNamefields with a name. The actual name used doesn't matter, I used "localdomain Root Certificate" for both fields. - Click the
Generate a new keybutton. Enter a name for the key. I used "Root Cert" for the name. - The default life of the certificate will be 10 years. If you need to change this, go to the
Extensionstab. - Click the
OKbutton at the lower right to generate and save the root certificate. - Export the root certificate using the
PEM (.crt)output format.
Creating a custom template for HTTPS server certificates to save some time
The [default] TLS_Server template contains all of the important settings needed for an HTTPS server's SSL certificate but it does not have any of the Subject tab's information filled in. If we make our own custom template, we can pre-fill some of those fields and save a little typing later on.
- Select the
Templatestab, - Click the
New Tepmplatebutton and then select the[default] TLS_serverfrom the templates popup window that appears, - Set the
Internal Namefield to be the name that we want to use for this template, - Fill in the remaining Subject page fields as you like. The only field that is important on this page is the
commonNamefield. We will set this to the hostname (or IP address) of the HTTPS server we are creating a certificate for when we use this template. Here, in the template definition, we should probably leave this blank, or maybe enter a template hostname like "*.localdomain", - Click the
OKbutton at the lower right to save this template.
Create a server certificate that is signed with your private CA's root certificate
Now we create the individual SSL server certificate for an HTTPS server.
- Select the root certificate we created previously and click the
New Certificatebutton. - Select the
Sourcetab and select either the name of the custom template created in the step above or[default] TLS_serverunderTemplate for new certificate. Click theApply allbutton, - Select the
Subjecttab and fill in theInternal Namefield with a name for this certificate and thecommonNamefield with the fully-qualified hostname or IP address of the server that will use this certifcate. - Click the
Generate a new keybutton. Enter a name for the key. I use the server hostname for the name. - The default life of the certificate will be 365 days. If you need to change this, go to the
Extensionstab. - Click the
OKbutton at the lower right to generate and save the root certificate. - Export both the server certificate combined with the CA certificate used to sign it by selecting the
PEM chain (*.pem)export format. - Switch to the
Private Keystab and export the private key created for this certificate using thePEM private (*.pem)export format. Change the output file's extension from "pem" to "key" so that it's clear that this is the key.
Installing the server certificate
On Fedora Apache web servers
- Set both the
SSLCertificateFileand theSSLCertificateChainFileoptions in theVirtualHostdefinition to be the server certificate file, i.e., the full chain file, exported in the step above. - Set the
SSLCertificateKeyFileoption in theVirtualHostdefinition to be the server's private key file exported in the step above. - Restart the httpd service
On a Unifi Dream Machine firewall/router/switch
- Copy the server's full chain file to
/mnt/data/unifi-os/unifi-core/config/unifi-core.crt - Copy the server's key file to
/mnt/data/unifi-os/unifi-core/config/unifi-core.key unifi-os restart
In the ntopng application on Linux
- Concatenate the server's full chain file and key file together into a single file called
ntopng-cert.pem. Place this file into the/usr/share/ntopng/httpdocs/ssldirectory and restart the application.
Trusting the CA certificate
In order to be able to trust the certificate being used by the webserver, each client must have a copy of the CA's root certificate in their CA trust configuration.
On Fedora Linux clients
- Put the certifcate authority root certificate that we exported during the first step above into the
/etc/pki/ca-trust/source/anchors/directory on each client, - Run the command
sudo update-ca-truston each client, - Reboot each client.