I've run into an issue with the nginxproxy/acme-companion
docker image. It obtains certificates with acme.sh
. As a result I get:
cert.pem (example.com) + chain.pem (R3 + ISRG Root X1)
== fullchain.pem
It also provides a tool that among other things verifies the certificates. It does it like so:
$ openssl verify -CAfile chain.pem fullchain.pem
I tried to investigate the issue:
$ openssl crl2pkcs7 -nocrl -certfile /etc/nginx/certs/example.com/fullchain.pem \
| openssl pkcs7 -print_certs -text -noout \
| egrep '(Issuer|Subject):'
Issuer: C=US, O=Let's Encrypt, CN=R3
Subject: CN=example.com
Issuer: C=US, O=Internet Security Research Group, CN=ISRG Root X1
Subject: C=US, O=Let's Encrypt, CN=R3
Issuer: O=Digital Signature Trust Co., CN=DST Root CA X3
Subject: C=US, O=Internet Security Research Group, CN=ISRG Root X1
So I guess the chain is: example.com <- R3 <- ISRG Root X1 <- DST Root CA X3
.
Now let's say I split fullchain.pem
into 3 files: example.com.pem
, R3.pem
, and ISRG-Root-X1.pem
and try to verify the certificates:
$ openssl verify -CAfile R3.pem example.com.pem
example.com.pem: OK
Succeeds because the ISRG Root X1 certificate is trusted.
$ openssl verify R3.pem
R3.pem: OK
Succeeds for the same reason.
$ openssl verify -CAfile ISRG-Root-X1.pem R3.pem
C = US, O = Internet Security Research Group, CN = ISRG Root X1
error 2 at 1 depth lookup: unable to get issuer certificate
error R3.pem: verification failed
I guess this fails because the issuer of the ISRG-Root-X1.pem
certificate is DST Root CA X3, which is not trusted. And this seems like the reason the original command fails:
$ openssl verify -CAfile chain.pem fullchain.pem
Can you suggest a command to verify a certificate that works for both Let's Encrypt and non-Let's Encrypt certificates?