Blog | G5 Cyber Security

CN=localhost: Server Certificate Issues

TL;DR

Using a certificate with CN=localhost on a server intended for wider deployment is problematic and will cause errors in most browsers. You need a proper, publicly trusted or internally signed certificate that matches your server’s domain name or IP address.

Why CN=localhost Doesn’t Work

Certificates with Common Name (CN) set to localhost are specifically for testing and development environments. Browsers treat them as untrusted because:

How to Fix It

Here’s a step-by-step guide to get a valid certificate for your server:

1. Choose a Domain Name

  1. Register a Domain: If you don’t have one, register a domain name (e.g., yourdomain.com).
  2. Use an IP Address: Alternatively, use your server’s public IP address if a domain isn’t feasible (though this is less common and can be problematic if the IP changes).

2. Obtain a Certificate

You have several options:

3. Install the Certificate

The installation process varies depending on your web server:

4. Configure Your Server

  1. Restart Web Server: Restart your web server (e.g., sudo systemctl restart nginx or sudo systemctl restart apache2) to apply the changes.
  2. Firewall: Ensure your firewall allows traffic on port 443 (HTTPS).

5. Test Your Certificate

Use an online SSL checker tool (e.g., SSL Shopper) to verify your certificate installation and configuration.

Exit mobile version