How to Configure Apache to Use a Purchased SSL Certificate

How to configure Apache to use a purchased SSL certificate

How to configure Apache to use a purchased SSL certificate

Buying an SSL certificate from a Certificate Authority is the easy part — clicking through a checkout page takes five minutes. Actually getting Apache to serve it correctly is where I see people get stuck, usually around the CSR generation or the chain file. I’ve installed purchased certificates on more servers than I can count, so let me walk you through the entire process from start to finish.

Why Buy an SSL Certificate Instead of Using Let’s Encrypt?

Free certificates from Let’s Encrypt are excellent for most use cases, but I still recommend purchased certificates in certain situations:

Prerequisites

Step 1: Generate a Private Key and CSR

Before purchasing, most CAs require a Certificate Signing Request (CSR), which I generate locally on the server (or securely transfer the resulting files if generated elsewhere):

openssl req -new -newkey rsa:2048 -nodes -keyout yourdomain.key -out yourdomain.csr

I’m prompted for details:

Country Name (2 letter code):        US
State or Province Name:              California
Locality Name:                       San Francisco
Organization Name:                   Your Company Inc.
Organizational Unit Name:            IT Department
Common Name:                         yourdomain.com
Email Address:                       admin@yourdomain.com

The Common Name must exactly match the domain you’re securing. For a wildcard certificate, I use *.yourdomain.com.

I keep yourdomain.key private and secure — this never gets shared with the CA or anyone else. Only the .csr file gets submitted.

Step 2: Submit the CSR to Your Certificate Authority

I log into the CA’s portal, paste the contents of yourdomain.csr:

cat yourdomain.csr

And follow their purchase/validation flow. Validation methods typically include:

I usually pick DNS or HTTP validation since they don’t depend on a specific mailbox existing.

Step 3: Download the Issued Certificate

Once validated and issued, the CA provides:

Step 4: Build the Full Certificate Chain

I combine the server certificate with the intermediate(s), in the correct order (server cert first, intermediates after, root excluded):

cat yourdomain.crt intermediate.crt > yourdomain-fullchain.crt

For more detail on getting chain order right, I have a dedicated guide on setting up SSL certificate chain files — it’s worth a look if you hit trust warnings after installation.

Step 5: Move Files to Their Proper Locations

sudo mkdir -p /etc/ssl/private
sudo cp yourdomain-fullchain.crt /etc/ssl/certs/
sudo cp yourdomain.key /etc/ssl/private/
sudo chmod 600 /etc/ssl/private/yourdomain.key
sudo chown root:root /etc/ssl/private/yourdomain.key

Step 6: Configure the Apache Virtual Host

<VirtualHost *:443>
    ServerName yourdomain.com
    DocumentRoot /var/www/yourdomain

    SSLEngine on
    SSLCertificateFile    /etc/ssl/certs/yourdomain-fullchain.crt
    SSLCertificateKeyFile /etc/ssl/private/yourdomain.key

    <Directory /var/www/yourdomain>
        Options -Indexes
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

I also set up a redirect from HTTP to HTTPS so visitors aren’t left on an unencrypted connection:

<VirtualHost *:80>
    ServerName yourdomain.com
    Redirect permanent / https://yourdomain.com/
</VirtualHost>

Step 7: Enable Required Modules and the Site

sudo a2enmod ssl
sudo a2ensite yourdomain.conf
sudo apachectl configtest
sudo systemctl reload apache2

Step 8: Harden the SSL Configuration

Since I’m already touching the SSL config, I take the opportunity to add solid baseline hardening:

SSLProtocol             all -SSLv3 -TLSv1 -TLSv1.1
SSLCipherSuite          ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384
SSLHonorCipherOrder     on
Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"

I cover deeper hardening (weak cipher removal, Perfect Forward Secrecy, OCSP stapling) in their own dedicated guides, since each deserves a proper treatment.

Step 9: Verify the Installation

I confirm the certificate and key match:

openssl x509 -noout -modulus -in /etc/ssl/certs/yourdomain-fullchain.crt | openssl md5
openssl rsa -noout -modulus -in /etc/ssl/private/yourdomain.key | openssl md5

Both hashes should be identical.

Then I check the live server response:

curl -vI https://yourdomain.com

And run an external test via SSL Labs for independent confirmation that the certificate, chain, and configuration are all correct.

Choosing the Right Certificate Type Before You Buy

Before generating a CSR, I make sure I’ve picked the right certificate type for the situation, since this affects both the CSR details and the validation process:

Getting this decision right before purchasing saves the hassle of reissuing or exchanging a certificate later if it turns out not to cover the domains you actually needed.

Common Mistakes I See

Security Best Practices

Performance Optimization Tips

Protocols h2 http/1.1

Troubleshooting

Problem: “SSL certificate problem: unable to get local issuer certificate” Missing or incorrectly ordered intermediate certificate. Rebuild your fullchain file with the correct order.

Problem: Apache won’t start after installing the certificate Run apachectl configtest for the specific error — commonly a path typo or a key/certificate mismatch.

Problem: Browser shows the certificate as valid, but curl fails Browsers sometimes cache intermediates from other sites. Rely on curl or openssl s_client for a true test of your server’s own configuration.

FAQs

How long does it take to get a purchased SSL certificate issued? Domain-validated certificates are often issued within minutes to a few hours. Organization- or Extended-Validation certificates can take one to several business days due to manual verification.

Can I reuse my private key when renewing a purchased certificate? Technically yes, but I generally recommend generating a fresh key pair at renewal time for better security hygiene.

Do I need to buy a new certificate for each subdomain? Not necessarily — a wildcard certificate covers all first-level subdomains of a domain, or a SAN certificate can cover multiple specific domains/subdomains under one certificate.

Summary and Key Takeaways

Installing a purchased SSL certificate in Apache comes down to generating a proper CSR, completing CA validation, correctly assembling the certificate chain, and configuring your virtual host with the right paths. Getting each step right the first time avoids the inconsistent trust warnings and downtime that come from a rushed installation.

Key takeaways:

References

Exit mobile version