DEV Community

Cover image for Installing a Free SSL Certificate on Shared Hosting, Step by Step
Adam Reeves
Adam Reeves

Posted on

Installing a Free SSL Certificate on Shared Hosting, Step by Step

Not every host renews certificates for you. Some shared plans ship with AutoSSL turned off, some run it only on the main domain, and some fail quietly when the validation file cannot be fetched. When that happens you are left with the manual path: generate a key pair, prove you control the domain, collect the files, and paste them into your hosting panel.

That path is worth knowing even if you never plan to use it. It takes about fifteen minutes the first time, and it is the same sequence every certificate authority expects.

Check what the server is actually serving

Before changing anything, find out what is on port 443 today:

echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null \
  | openssl x509 -noout -subject -issuer -dates
Enter fullscreen mode Exit fullscreen mode

Read three things: the subject should match your hostname, the issuer should be a real CA, and notAfter should be in the future. If the subject is the host's own name, or the dates are stale, the certificate is not being managed for your domain.

A browser-based checker gives the same answer without a terminal, which is handy when you are working from a phone. TryFreeSSL's live SSL checker shows the issuer, the days remaining and the server for any hostname, and it is also where the certificate in this guide can be issued, so the check and the issuance happen in one place.

Generate the private key and the CSR

A certificate authority signs a public key, and the CSR is how you hand that public key over:

openssl req -new -newkey rsa:2048 -nodes \
  -keyout example.com.key -out example.com.csr \
  -subj "/CN=example.com"
Enter fullscreen mode Exit fullscreen mode

Two details matter. -nodes leaves the key unencrypted so the web server can read it without a passphrase at startup. And the key file must stay private: never paste it into a support ticket, never commit it, never email it. For a wildcard, use CN=*.example.com, but note that wildcards need DNS validation, which we get to below.

If you have no shell access, which is normal on shared hosting, a CSR generator does the same work in the browser and gives you the CSR text plus a key file to download. Whatever tool you use, make sure the private key is generated in a place where you can keep it, and clear it from the tool afterwards if the tool offers that.

Prove you control the domain

The CA will not sign anything until you show you control the hostname. Two methods cover almost everything:

HTTP validation. You publish a small file under /.well-known/acme-challenge/ containing a token the CA gives you. Create the directory, upload the file, confirm it loads over plain HTTP, then ask for validation.

DNS validation. You add a TXT record named _acme-challenge.example.com with the token as its value. This is the only option for wildcards, and it is more reliable when the site sits behind a proxy or a CDN that swallows unknown paths.

Two traps here. If the site already redirects HTTP to HTTPS and the current certificate is broken, the validator can follow the redirect into a failed TLS handshake, so let the challenge path through unredirected. And DNS changes can take a while to appear, so give a TXT record time before you retry, rather than firing the same request repeatedly.

Collect the three files

When issuance finishes you get three pieces:

  • The certificate itself (.crt or .pem), for your domain.
  • The private key (.key) you generated earlier.
  • The CA bundle, sometimes called the intermediate or chain file.

The common mistake is installing the certificate alone. Some browsers will paper over the missing intermediate, but curl, Android clients and most API integrations will not. If a checker says the chain is incomplete, you are missing the bundle.

Install it in cPanel

In cPanel, open SSL/TLS then Manage SSL Sites. Some hosts put the same screen under SSL/TLS Status with an Install an SSL certificate button. You paste the domain, the certificate, the key and the CA bundle into their own fields, then install.

Order matters inside the certificate field when a host asks for a single combined box: your certificate first, then the bundle underneath it. Reversing them produces an error that reads like a bad key.

On hPanel, Plesk or a custom panel the labels differ, but the three inputs are always the same three things.

Verify, then force HTTPS

Reload the checker or rerun the openssl command. The subject, issuer and dates should now be yours.

Then redirect plain HTTP:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Enter fullscreen mode Exit fullscreen mode

Expect mixed content next. A page can be served over HTTPS and still show as insecure because one image, font or script is requested over http://. The fix is to update those references, not to disable the warning. On WordPress that usually means a database search and replace from http://example.com to https://example.com; use a tool that handles serialized data, or the site's settings will break in confusing ways. Check the browser console after the change, because a single hard-coded http:// URL in a theme is easy to miss and hard to spot by eye.

Plan the renewal before you need it

A ninety-day certificate is a file with a date on it, not a subscription. Renewal means doing this whole install again unless something automates it for you. Put the expiry date somewhere you actually look, with a reminder two weeks out, and check the chain again around day sixty rather than the day it dies.

If your host offers AutoSSL, turn it on and confirm it is really running on your domain. If it does not, and you have more than a couple of sites, the honest answer is that manual installation is a fallback, not a strategy: at some point a date will pass while you are busy with something else, and the first person to notice will be a customer.

When the manual path is the right one

Manual installation earns its place in a few situations: a single site on a host without automation, a migration where DNS and hosting are temporarily split, a wildcard for an internal tool, or a host whose automated renewal keeps failing validation for reasons you cannot see. In those cases the sequence above is the whole job, and doing it once by hand teaches you exactly which step the automation is getting wrong.

Top comments (0)