MENTECHLet’s talkالعربية
Menu

Fix a certificate with the wrong address

Give it the right name.

The server shows a certificate that belongs to another address, so browsers warn your visitors. It usually means one name was left out, often the one with or without www.

Before you start

  • Whoever runs your server or hosting can do this. Send them this page.
  • Write down every address the certificate must cover. Our check lists the ones it covers now.
  • A certificate for *.example.com covers shop.example.com. It does not cover example.com or a.shop.example.com.

The steps

First add the missing name to the site's server_name line. Then list the names you have with sudo certbot certificates, and ask again for all of them plus the missing one. Any name you leave out is dropped. On Debian and Ubuntu, this also needs: sudo apt install python3-certbot-nginx

sudo certbot --nginx --cert-name example.com -d example.com -d www.example.com

Then check the settings and reload.

sudo nginx -t && sudo nginx -s reload

If it shows an error, or the site stops, put the saved copy back and restart the server program at once.

Check that it worked

openssl s_client -connect example.com:443 -servername example.com -verify_hostname example.com </dev/null 2>/dev/null | grep "Verify return"

The answer should be 0 (ok). Repeat it with www. Run it on the server. The openssl that comes with a Mac cannot do this.

To undo it

Put the previous certificate back. Keep it until the new one is confirmed.

Common mistakes

  • Adding only the missing name and losing the others.
  • Testing only one address. Check the site with www and without it.
Have us fix it for you
CallWhatsAppLet’s talk