-1

Using Nginx and Let's Encrypt, I have a domain example.com which is secured by Let's Encrypt.

I have another domain name example.net which is redirected as bellow :

server {
    listen 80;
    listen 443;
    server_name example.net *.example.net;

    return 301 https://example.com$request_uri; 
}

All the Uri's http://www.example.net , http://example.net, www.example.net, example.net returns https://example.com and no problem.

When I type https://www.example.net or https://example.net the Warning on browser is :

Firefox does not trust this site because it uses a certificate that is not valid for example.net . The certificate is only valid for the following names: example.com, www.example.com

Error code: SSL_ERROR_BAD_CERT_DOMAIN

I need to know that should I add/get certificate for example.net in addition to my main domain example.com ?? So I need to, two certificates to resolve this problem or any other solution ?

ehsan_kabiri_33
  • 145
  • 2
  • 8
  • 2
    You don’t need two certificates. When you try to fetch a new certificate for all the required domains, you will be asked if you would like to add the additional domains to the existing certificate. – Pothi Kalimuthu Apr 26 '21 at 14:54
  • Thanks for replying. But most of the people will panic, while exposing/seeing this warning and might leave the web page! I need no alert/warning – ehsan_kabiri_33 Apr 27 '21 at 05:20
  • I assume that is an incomplete config or `listen 443;` would make no sense without references to the SSL files. You don't need two certificates if you have subject alt names with the connect certs – Timothy c Apr 28 '21 at 20:27

1 Answers1

1

Your current setup does not provide a valid certificate for this domain. To fix it, you have two options:

  1. Replace the existing certificate with a certificate that covers www.example.net, example.net, www.example.com and example.com. Use the certificate in all virtual host blocks in your configuration.

  2. Have two different certificate, one for example.net and www.example.net and second one for example.com and www.example.com. Then, add each certificate to corresponding virtual host block.

Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63