Adding a wildcard SSL certificate to your WordPress site
So this one threw me for a little bit of a loop when I was first trying to figure it out, even though it shouldn’t have. I was just overthinking it. There was plenty of documentation out there for adding a certificate to a single site, but there is not much when it comes to adding a wildcard certificate to a multi-site WordPress install. I guess that was where I had gotten confused. For reference, this was the specific KB article that helped me the most.
For folks that don’t know what I’m talking about, a multi-site install is one where you can host different WordPress sites on the same server. Meaning that site1.<yoursite>.com and site2 .<yoursite>.com could both reside on the same server even if they are about completely different content. Thus you would only have to cover the cost to host one server, instead of paying for two, one for each host. Yes, they do share some resources, so there are some possible drawbacks… But for most personal sites it should not really be an issue for a few sites to share the same host.
You will need OpenSSL installed on your machine before we continue. It’ll likely already be installed if you are using LInux. If it’s not installed please use your OS’s package manager to install it.
Generate a new private key:
sudo openssl genrsa -out /opt/bitnami/apache2/conf/server.key 2048
Use that key to create a certificate:
***IMPORTANT: Enter the server domain name when the below command asks for the “Common Name”.***
sudo openssl req -new -key /opt/bitnami/apache2/conf/server.key -out /opt/bitnami/apache2/conf/cert.csr
Send the cert.csr file to your Certificate Authority (CA). After they complete their validation checks, they will issue you your new certificate.
Download your certificates. You should have received two files, one was your new certificate and the other file is the CA’s certificate. Rename them as follows:
- STAR_YourSite_com.crt –> server.crt
- STAR_YourSite_com.ca-bundle –> server-ca.crt
Backup your private key after generating a password-protected version in the pem format.
sudo openssl rsa -des3 -in /opt/bitnami/apache2/conf/server.key -out privkey.pem
Note: To regenerate the key and remove the password protection, you can use this command:
sudo openssl rsa -in privkey.pem -out /opt/bitnami/apache2/conf/server.key
We’re almost done. Next you’ll open the Apache configuration file to verify it’s setup to use the certificates you just uploaded. The config file can be found at: /opt/bitnami/apache2/conf/bitnami/
Scroll down until you find “<VirtualHost _default_:443>” and verify that it is pointing to the correct certificate, key, and CA certificate bundle that you uploaded earlier. You should find the below lines, if you don’t, go ahead and add them.
SSLCertificateFile "/opt/bitnami/apache2/conf/server.crt" SSLCertificateKeyFile "/opt/bitnami/apache2/conf/server.key" SSLCACertificateFile "/opt/bitnami/apache2/conf/server-ca.crt"
Note: It’s easiest to use these default names and not a custom name for these files. If you use a custom name you might need to update that name in other spots of the Apache config file, and you’ll have to google that on your own. If your cert/key is using another name, I recommend just renaming them to the default names above that Apache uses.
After we have copied our files over and have verified that the Apache config file is correct, we are going to update the file persmissions on our certificate files. We will make them readable by the root user only with the following commands:
sudo chown root:root /opt/bitnami/apache2/conf/server* sudo chmod 600 /opt/bitnami/apache2/conf/server*
Open port 443 in the server firewall. If you’re using Bitnami you can reference this KB.
Restart your server.
Once it comes up, you should now be able to connect to your site using HTTPS.
- If you are looking for where to purchase an SSL certificate, check out SSLs.com. I use them for my projects. I’ve shopped around, and they have the best deals that I have found anywhere on the Internet.