Renew(?) Expired Certificate

A couple months ago I set up an RPi as a test web server. A week ago, my Let’s Encrypt certificate expired and wasn’t renewed. This is my first time dealing with such things, and I’m not sure where to go from here. E.g., can the certificate be ‘fixed’, or do I need a new one?

I verified that the actual website works, and can be accessed via http.

My hardware and software:

 - Device model : RPi 3 Model B+ (aarch64)
 - Let's Encrypt Cert : Valid until 2026-Aug-5 01:47:56
 - systemd status : No services failed
 
  [ ] 0    OpenSSH Client: Feature-rich SSH, SFTP and SCP client
  [ ] 1    Samba Client: access SMB/CIFS/Samba network shares
  [ ] 84   Lighttpd: Extremely lightweight webserver
  [ ] 88   MariaDB: Persistent cached file-per-table database server
  [ ] 89   PHP: Hypertext Preprocessor for dynamic web content
  [ ] 92   Certbot: Obtain and renew Let's Encrypt SSL certs for HTTPS
  [ ] 96   Samba Server: Feature-rich SMB/CIFS server
  [ ] 103  DietPi-RAMlog: Makes /var/log a RAM disk, preserves file structure on reboot
  [ ] 105  OpenSSH Server: Feature-rich SSH server with SFTP and SCP support

My services:

       ●─ Single Service Options -------------●
nmbd              : enabled | included | Affinity 0-3
smbd              : enabled | included | Affinity 0-3
mariadb           : enabled | included | Affinity 0-3
php8.4-fpm        : enabled | included | Affinity 0-3
lighttpd          : enabled | included | Affinity 0-3
cron              : enabled | included | Affinity 0-3
ssh               : enabled | included | Affinity 0-3
dietpi-vpn        : disabled | included | Affinity 0-3
dietpi-cloudshell : disabled | included | Affinity 0-3
noip-duc          : enabled | included | Affinity 0-3
Add               : Add missing service to DietPi-Services

Running certbot:

sudo certbot renew --dry-run
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/MY_SITE.net.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Account registered.
Simulating renewal of an existing certificate for MY_SITE.net

Certbot failed to authenticate some domains (authenticator: webroot). The Certificate Authority reported these problems:
  Domain: MY_SITE.net
  Type:   unauthorized
  Detail: 73.128.102.145: Invalid response from http://MY_SITE.net/.well-known/acme-challenge/8dtxEOrVkqLiIz9eLAsILqfjgaH-KYeGYrqxWibkmig: 404

Hint: The Certificate Authority failed to download the temporary challenge files created by Certbot. Ensure that the listed domains serve their content from the provided --webroot-path/-w and that files created there can be downloaded from the internet.

Failed to renew certificate MY_SITE.net with error: Some challenges have failed.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
All simulated renewals failed. The following certificates could not be renewed:
  /etc/letsencrypt/live/MY_SITE.net/fullchain.pem (failure)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1 renew failure(s), 0 parse failure(s)
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details.

I do not have a “.well-known/” directory.

TIA for any push in the right direction.

Hello Torgo,
is the server publicly accessible?

It’s normal that you don’t see .well-known directory, it’s only created temporarily when the renewal happens.

If the webserver is generally accessible from outside your local network:

  • Create the ACME challenge file manually, and try to access that from browser:
    mkdir -p /var/www/.well-known/acme-challenge
    touch /var/www/.well-known/acme-challenge/8dtxEOrVkqLiIz9eLAsILqfjgaH-KYeGYrqxWibkmig
    
  • Then try to access the following URL:
    http://MY_SITE.net/.well-known/acme-challenge/8dtxEOrVkqLiIz9eLAsILqfjgaH-KYeGYrqxWibkmig
    
  • If that works, verify that the certbot config uses /var/www as webroot:
    grep webroot /etc/letsencrypt/renewal/MY_SITE.net.conf
    

Aha! I’ve actually got it set up to use www/html as webroot. I guess that’s not normal, but the only other web server I’ve set up configured it that way.

Fixed the .conf file, reran certbot, and it’s good to go. I’m guessing the automatic renewal will work now?

When installed via dietpi-software, the web root is set to /var/www.

I see that. I’ve changed the MY_SITE.net.conf entries for webroot_path = and MY_SITE.net = to /var/www/html which made certbot happy. I’m assuming the next renewal will just invoke certbot again.

I just realized that you meant that the web server itself is set up to use /var/www as web root, and indeed it was; I had changed to be consistent with the way my LAN web server is set up.

Yes, changing it to /var/www/html in the certbot config broke it, not made it happy.

Of course you can change the webroot to /var/www/html in both ends. But software which use a webserver are installed to /var/www direct subdirs, not /var/www/html, hence they wouldn’t work until manually moved. Also dietpi-letsencrypt expects /var/www for Lighttpd.

Well, it worked this time around. I’m a little confused about how it worked when I first set it up. I thought I did all the configuration before I added the certificate, but perhaps I’m misremembering.

So, I’d be better off re-configuring everything to use /var/www as root?

I don’t know which software you have installed, and where it is located now. Just keep in mind that everything installed via dietpi-software (which uses the system webserver) gets installed to /var/www. But you are free to choose depending on your needs.