This was going to be a question about why is it OK, that when renewing a certificate with the certonly subcommand, it doesn't run pre/post hooks (only deploy hooks) but the renew subcommand runs all of them. It didn't make sense to me that they wouldn't be run for any renewal, even when done via certonly, which is recommended by the user guide when you want to renew only one certificate instead of all of them. The user guide does only say that pre/post hooks are run with the renew subcommand, it doesn't mention certonly in relation to them, but that seemed wrong.
I think the user guide is giving bad guidance in this case. If you want to renew a single certificate, the only reliably correct to do it is to use the renew subcommand with --cert-name (and possibly --force-renewal).
Do not use the certonly subcommand with --cert-name (and possibly --force-renewal).
The user guide recommends this, but it doesn't always work, and the consequences can be bad. The certonly and renew subcommands are very different (even when --force-renewal is used with both so they are both renewing).
- certonly doesn't run pre/post hooks
- certonly doesn't seem to consult some [renewalparams] in the renewal config file
- certonly removes some [renewalparams] from the renewal config file
This means that, if you did run/certonly/renew --reuse-key in the past, and have "reuse_key = True" in your renewal config file, and you have it there for a reason (e.g. DANE), the renew subcommand will honour it, but the certonly subcommand will ignore it and create a new keypair, and delete "reuse_key = True" from the renewal config file. This could be disastrous.
It also ignores the stored authenticator parameter as well, which is an inconvenience.
And there might be other parameters that it ignores and then removes.
But presumably, it does use the "account" parameter or it wouldn't work at all. It's strangely selective about which [renewalparams] it uses and which ones it doesn't use (and then discards).
Admittedly, it's fine if you don't need pre/post hooks for the renewal to work, and if you don't have anything important in your [renewalparams], but the user guide doesn't know that. It should provide recommendations that always work, or explain when their recommendations do and don't work.
And I could have also supplied --reuse-key along with certonly, and it would have done what I wanted (I just checked), but I knew that it had been saved in the renewal config file, and so it never occurred to me that I would have to supply it again. Certbot already knew I wanted to reuse the key. It was in the renewal config file. That's what persistence means.
Should I log an issue for the user guide to be changed so as to not recommend certonly for renewals?
Should I log an issue for certonly to be changed to act exactly like renew (and so do renewals properly) when it is renewing a certificate, rather than obtaining an entirely new one that wasn't there before?
I think the second is the better option (fewer surprises), but the first might be actioned quicker and help people using older versions of certbot.
On the other hand, the existing certonly behaviour could be desirable as a way of erasing, via the command line, all previously persisted [renewalparams] from the renewal config file. But it's not documented as having that purpose. Although some users may have noticed it and be using it in that way.
It might seem obvious that it's better to use renew than certonly for renewals, and no doubt, that's clear in hindsight, but the problem is that the user guide recommends it, and the certonly subcommand appears to go along with it (by accepting the --force-renewal option), just badly.
Any thoughts?
cheers,
raf