0

I installed lets encrypt using certbot when I go to the www.domain.com I get this site is not secure error

Found the following certs:
  Certificate Name: example.com
    Domains: example.com
    Expiry Date: 2023-05-25 15:01:00+00:00 (VALID: 70 days)
    Certificate Path: /etc/letsencrypt/live/example.com/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/example.com/privkey.pem
  Certificate Name: www.example.com
    Domains: www.example.com
    Expiry Date: 2023-06-13 16:14:03+00:00 (VALID: 89 days)
    Certificate Path: /etc/letsencrypt/live/www.example.com/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/www.example.com/privkey.pem

Apache SSL conf file

<VirtualHost *:443>
ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example/public_html/public
SSLEngine                on
<Directory /var/www/example/public_html/public>
         Options +FollowSymLinks
         DirectoryIndex index.php
         AllowOverride All
         Require all granted
         Order allow,deny
         Allow from all
     </Directory>
SSLCertificateFile       /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile    /etc/letsencrypt/live/example.com/privkey.pem
Include  /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

How can I make it work for www domain also?

Utku Dalmaz
  • 1,329
  • 2
  • 13
  • 18

1 Answers1

1

You need to get one certificate with correct Subject Alternate Name.

You can delete the www.example.com and example.com certificates, and request a new for example.com and wwww.example.com.

vidarlo
  • 6,654
  • 2
  • 18
  • 31
  • How can I delete only www certificate? because If I delete both of them, site will be broken. Can I first delete the www cert. and then convert example.com to wildcard? – Utku Dalmaz Mar 16 '23 at 13:21
  • You don't need wildcard. You need a cert with two names. `certbot delete --certname www.example.com` should do the trick. And yes; the site *will* be broken for some seconds when you switch over anyway. – vidarlo Mar 16 '23 at 13:37