Testing certbot

certbot 1.21.0
Ubuntu 22.04

certbot certificates is listing my certificates and shows that they are going to expire in 4 days. I also got a reminder email warning me about that a couple of days ago.

Reason why I'm asking: I moved to a new server (from 32bit to 64bit Ubuntu recently). I also migrated (copied) everything from /etc/letsencrypt to the new server.
I'm not running a webserver.

For the moment I forgot, which challenge my installation is using.

How can I test

  1. whether certbot would "heal" the upcoming expiration beforehand by itself automatically?
    (it looks like the expiration would occur unevitably)

  2. if certbot is setup for automatic renewals and whether it can be found in some cron files?

I tried this and got:

root@mail:~# certbot renew --dry-run
Another instance of Certbot is already running.
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /tmp/tmpn47tbydo/log or re-run Certbot with -v for more details.
root@mail:~# ps ax | grep certbot
  43512 ?        Ss     0:00 /usr/bin/python3 /usr/bin/certbot -q renew
  43526 pts/0    S+     0:00 grep --color=auto certbot
root@mail:~# 

And to add some more findings:

# /etc/cron.d/certbot: crontab entries for the certbot package
#
# Upstream recommends attempting renewal twice a day
#
# Eventually, this will be an opportunity to validate certificates
# haven't been revoked, etc.  Renewal will only occur if expiration
# is within 30 days.
#
# Important Note!  This cronjob will NOT be executed if you are
# running systemd as your init system.  If you are running systemd,
# the cronjob.timer function takes precedence over this cronjob.  For
# more details, see the systemd.timer manpage, or use systemctl show
# certbot.timer.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(43200))' && certbot -q renew

No.

Check if there's some systemd timers. (systemctl list-timers)

4 Likes

Some more datapoints:

in /var/syslog I find:

Oct 22 06:33:56 mail certbot[34963]: Failed to renew certificate mail.kukulies.org with error: The requested apache plugin does not appear to be installed

In this forum I found:

about this issue, but neither the apt package can be found nor the cited link works (Error 404)

root@mail:/var/log# certbot plugins
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* standalone
Description: Spin up a temporary webserver
Interfaces: Authenticator, Plugin
Entry point: standalone = certbot._internal.plugins.standalone:Authenticator

* webroot
Description: Place files in webroot directory
Interfaces: Authenticator, Plugin
Entry point: webroot = certbot._internal.plugins.webroot:Authenticator
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
root@mail:/var/log# 

To answer your question about system timers:

Mon 2023-10-23 19:08:37 CEST 8h left     Mon 2023-10-23 09:27:36 CEST 49min ago    certbot.timer                  certbot.service

Meanwhile I got into the right direction. My apache2 had start problems. Some modules were missing. Mainly apt install python3-certbot-apache and some others. (I neglected apache2 a bit, since it was not primarily the goal to run a web server. mail server is the primary task)

This should solve the missing plugin issue, assuming you installed certbot via apt.

But you can also adapt to using the webroot plugin. Have you seen its documentation?

4 Likes

The recommended installation method for Ubuntu 22 is via snap [not apt].
[version 2.7.2 is the latest]
See: Certbot (eff.org)

3 Likes

If that remains there for too long, please show the renewal config files.
[which will undoubtedly show that Apache installer/authenticator is required - and hasn't been installed]

2 Likes

I remember that certbot once was running under snapd but since there were no 32bit snapd updates available any longer, that's one reason I moved to Ubuntu 64bits.

root@mail:~# certbot plugins
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* apache
Description: Apache Web Server plugin
Interfaces: Installer, Authenticator, Plugin
Entry point: apache = certbot_apache._internal.entrypoint:ENTRYPOINT

* standalone
Description: Spin up a temporary webserver
Interfaces: Authenticator, Plugin
Entry point: standalone = certbot._internal.plugins.standalone:Authenticator

* webroot
Description: Place files in webroot directory
Interfaces: Authenticator, Plugin
Entry point: webroot = certbot._internal.plugins.webroot:Authenticator
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
root@mail:~# ps ax | grep certbot
   4751 pts/0    S+     0:00 grep --color=auto certbot
root@mail:~# 

And:

root@mail:~# apt list certbot
Listing... Done
certbot/jammy,now 1.21.0-1build1 all [installed]
root@mail:~# 

I installed snapd now successfully. How should I proceed from here?

Did you first remove certbot from apt?:


See: Certbot Instructions | Certbot (eff.org)

3 Likes

OK, I misunderstood. I have removed certbot now (apt remove certbot).

Got now to here:

root@mail:/var/log#  snap install --classic certbot
2023-10-23T17:19:28+02:00 INFO Waiting for automatic snapd restart...
certbot 2.7.2 from Certbot Project (certbot-eff✓) installed
root@mail:/var/log# 

And further:

certbot renew. worked!
certbot certificates is showing updated certificates

remains the question that renweal after 30 will run automatically.

Renewals usually run after 60 days (30 days remaing before expiry of cert).

The auto-renew should have been setup during install of snap Certbot. You can check that with instructions at link below. But, yes, definitely confirm it does manually too.

https://eff-certbot.readthedocs.io/en/latest/using.html#automated-renewals

3 Likes

Sorry, mixed it up (60 vs. 30 days)

systemtcl list-timers
Mon 2023-10-23 23:17:00 CEST 5h 23min left n/a                          n/a           snap.certbot.renew.timer       snap.certbot.renew.service

It might have been as simple as a hanging process previously which would prevent automatic renewal (as there already was a running Certbot) every time Certbot was run using cron or systemd timer. Apparently with removing the apt Certbot and installing the snap Certbot, this has been fixed.

No absolute guarantees of course, but as snap installs a renew job and the renewal worked just now, you should be good to go for future renewals.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.