tl;dr Problem caused by a manually installed root certificate in /etc/ssl/certs/ and was solved by removing this.
We experienced the same issue on our servers (Ubuntu 20.04.3 fully patched and running openssl 1.1.1f) on Friday, when the ca-certificates package was automatically updated.
Connecting to a domain with a LE certificate returned the error
verify error:num=2:unable to get issuer certificate
On a freshly installed and fully updated Ubuntu 20.04.3 running the same openssl version there was no such error.
What I could see from the output was that on our servers the certificate chain contained the DST Root CA X3
certificate while on the freshly installed server it contained the R3
certificate from LE.
I discovered that the reason for this was that we had manually installed a copy of the DST Root CA X3
into /etc/ssl/certs/ on our servers and for some reason this was being used by openssl instead of the R3
certificate.
Removing the manually installed certificate solved our problems.
Output with /etc/ssl/certs/lets-encrypt-r3-cross-signed.pem
$ openssl s_client -connect valid-isrgrootx1.letsencrypt.org:443 > /dev/null
depth=1 C = US, O = Let's Encrypt, CN = R3
verify error:num=2:unable to get issuer certificate
issuer= O = Digital Signature Trust Co., CN = DST Root CA X3
verify return:1
depth=0 CN = valid-isrgrootx1.letsencrypt.org
issuer= C = US, O = Let's Encrypt, CN = R3
verify return:1
Output without /etc/ssl/certs/lets-encrypt-r3-cross-signed.pem
$ openssl s_client -connect valid-isrgrootx1.letsencrypt.org:443 > /dev/null
depth=2 C = US, O = Internet Security Research Group, CN = ISRG Root X1
verify return:1
depth=1 C = US, O = Let's Encrypt, CN = R3
verify return:1
depth=0 CN = valid-isrgrootx1.letsencrypt.org
verify return:1
I hope that this information can be useful for someone having the same issue.