The reason I'm not sure is because I think I have ended up with two separate certificates, and wonder whether the --expand parameter above would only work if I'd created a single one.
Hi @Jonathan9, and welcome to the LE community forum
I don't think you can request a wildcard cert that also includes domains that would be covered by the wildcard cert. *.domain1.com
covers: www.domain1.com
This is not necessarily a bad thing.
Could you put all the names on one cert? Probably.
Should you? Maybe and maybe not.
[there is no wrong answer]
Essentially, the --expand option will confirm Certbot's choice of a random one of the two to replace with the expanded certificate, if there are two possible certificates for which the new certificate would be a possible expansion.
If you want to pick a particular one, you can use the --cert-name option to specify which certificate name the new certificate ought to be saved under. Otherwise the choice that Certbot makes is essentially arbitrary from the user's point of view (I think it might likely be the one with the alphabetically first cert name).
I know --apache works so want to use it again, which means there are two reasons not to use that wildcard. I'll get certificates for the two existing subdomains for now.
That command should result with a single certificate for all those hostname, overwriting your previous domain1.com certificate, assuming it's name is actually domain1.com and not www.domain1.com. You can check the cert names by running certbot certificates.
Also note that the apache installer should be smart enough to update the current reference to your now-current but then old domain2.com certificate to the then newly issued domain1.com cert, but it doesn'r hurt to verify that!
Also note that if everything is set up correctly in Apache, you're satisfied with your single cert containing all the hostnames, you should delete the now-unnecessary domain2.com cert. Otherwise it keeps renewing unnecessarily indefinitely while not in use. Which would be a shame of Let's Encrypt resources.
An unexpected error occurred:
ValueError: Unable to set value to path!
I'm in a rush to leave the house now, but will add more details later... I wonder whether this is an obvious error to explain, though, even without full details.
Edit: I logged in as root, typed the same command (minus sudo) and it worked fine. Here is the final result:
Did you double check if your webserver configuration is only pointing to the files in /etc/letsencrypt/live/domain1.com/? Otherwise your webserver won't (re)start as it'll be missing critical files if it's still using the files from the /live/domain2.com/ directory.