Issue - Unable to verify certificate chain - CentOS7

Greetings,

Issue:
Issue - Unable to verify certificate chain - CentOS7

Summary:
I issued a let'sencrupt via Certbot installed on a Pi, my DNS server is Cloudflare.
I was able to get the cert files without issues.

root@raspberrypi# certbot --version
certbot 1.12.0
[root]# ls
0-server.key  1-server.crt  2-inter.crt  3-root.crt  chain.crt  fullchain.crt
[root]# openssl x509 -in 1-server.crt -noout -issuer
issuer= /C=US/O=Let's Encrypt/CN=R3
[root]# openssl x509 -in 2-inter.crt -noout -issuer
issuer= /C=US/O=Internet Security Research Group/CN=ISRG Root X1
[root]# openssl x509 -in 2-inter.crt -noout -issuer
issuer= /C=US/O=Internet Security Research Group/CN=ISRG Root X1

Now when I run the following command to verify, getting error:

[root]# openssl verify -CAfile 2-inter.crt 1-server.crt
1-server.crt: C = US, O = Let's Encrypt, CN = R3
error 2 at 1 depth lookup:unable to get issuer certificate

My web server showing error as well when using the cert:

  Missing CA: /O=Digital Signature Trust Co./CN=DST Root CA X3 (2e5ac55d).
       Error: Unable to verify certificate chain.
Error: Unable to validate web_service_certificate

Any idea why the chain validation is broken?

Note: When I use a self-signed certificate chain (Root-Inter-leaf) everything works fine (I just need to add the root to the trust store, that's why I am trying to use Let's encrypt, however, it's failing.

Regards,

1 Like

The best way to use openssl to verify a local cert is shown here (by a certbot dev):

What command are you trying when your webserver says "Unable to validate web_service_certificate"?

Can you describe your web server? And, is this still your ans.red domain from earlier posts? If not, which domain is it?

9 Likes

Hi @MikeMcQ . thanks for helping out here.

The domain is different, illumio.consulting

The error Unable to validate web_service_certificate is from the web server software itself.

I tried the verify command from the link you shared, between root and intermediate + intermediate + server and I got:

I noticed when checking the command on my Macbook, and it shows it's okay

# openssl verify -untrusted 3-root.crt 2-inter.crt

2-inter.crt: OK

# openssl verify -untrusted 2-inter.crt 1-server.crt

1-server.crt: OK

But on the CentOS 7 machine,

# openssl verify -untrusted 3-root.crt 2-inter.crt
2-inter.crt: C = US, O = Internet Security Research Group, CN = ISRG Root X1
error 2 at 1 depth lookup:unable to get issuer certificate


# openssl verify -untrusted 2-inter.crt 1-server.crt
1-server.crt: C = US, O = Internet Security Research Group, CN = ISRG Root X1
error 2 at 2 depth lookup:unable to get issuer certificate

Anything else I should check to verify the certificate is valid on a CentOS 7 machine and it's able to validate the chain?

1 Like

I don't know why the server would verify the cert. Usually the server just sends out the cert and the client verifies that it is trusted in their CA store. A server can't possibly know whether a client will trust the certs.

Setting that aside, the verify error sounds like your CA root store does not have the ISRG Root X1 cert in it. You could try updating that with

sudo yum install ca-certificates
9 Likes

ca-certificate already installed

# sudo yum install ca-certificates
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink                                                                                 |  20 kB  00:00:00
 * base: mirror.dst.ca
 * epel: mirror.dst.ca
 * extras: mirror.dst.ca
 * updates: mirror.xenyth.net
base                                                                                                 | 3.6 kB  00:00:00
epel                                                                                                 | 4.7 kB  00:00:00
extras                                                                                               | 2.9 kB  00:00:00
updates                                                                                              | 2.9 kB  00:00:00
(1/2): epel/x86_64/updateinfo                                                                        | 1.1 MB  00:00:00
(2/2): epel/x86_64/primary_db                                                                        | 7.0 MB  00:00:01
Package ca-certificates-2021.2.50-72.el7_9.noarch already installed and latest version
Nothing to do

I used this other command as well to confirm the ISRG Root X1 certificate if it's there.

awk -v cmd='openssl x509 -noout -subject' ' /BEGIN/{close(cmd)};{print | cmd}' < /etc/ssl/certs/ca-bundle.crt

and I can see the root cert

subject= /C=US/O=Internet Security Research Group/CN=ISRG Root X1

1 Like

Hmmm. I am on a similar system and get this when verifying an LE cert:
(pwd is the /etc/letsencrypt/live/(domain)/ folder)

openssl verify -untrusted chain.pem cert.pem
cert.pem: OK

What happens with:

openssl verify -untrusted 2-inter.crt 1-server.crt -CAfile /etc/ssl/certs/ca-certificates.crt
9 Likes

Getting this

# openssl verify -untrusted 2-inter.crt 1-server.crt -CAfile /etc/ssl/certs/ca-certificates.crt

1-server.crt: C = US, O = Internet Security Research Group, CN = ISRG Root X1
error 2 at 2 depth lookup:unable to get issuer certificate

Error opening certificate file -CAfile
139794605307792:error:02001002:system library:fopen:No such file or directory:bss_file.c:402:fopen('-CAfile','r')
139794605307792:error:20074002:BIO routines:FILE_CTRL:system lib:bss_file.c:404:
unable to load certificate

Error opening certificate file /etc/ssl/certs/ca-certificates.crt
139794605307792:error:02001002:system library:fopen:No such file or directory:bss_file.c:402:fopen('/etc/ssl/certs/ca-certificates.crt','r')
139794605307792:error:20074002:BIO routines:FILE_CTRL:system lib:bss_file.c:404:
unable to load certificate

Might be something wrong with CA store on the system, not sure what could be though

Oh, my bad. Should be:

openssl verify -untrusted 2-inter.crt -CAfile /etc/ssl/certs/ca-bundle.crt 1-server.crt
9 Likes

it's okay, here is the output

# openssl verify -untrusted 2-inter.crt -CAfile /etc/ssl/certs/ca-bundle.crt 1-server.crt
1-server.crt: C = US, O = Internet Security Research Group, CN = ISRG Root X1
error 2 at 2 depth lookup:unable to get issuer certificate

I don't understand how that can be. You found the ISRG root in that CA store with your awk command a few posts back. Are you sure those files 2-inter.crt and 1-server.crt are the chain.pem and cert.pem, respectively, created by certbot?

As evidence this is what I get :slight_smile: I have the same CA cert store version as you.

openssl verify -untrusted chain.pem -CAfile /etc/ssl/certs/ca-bundle.crt cert.pem
cert.pem: OK
9 Likes

What is the output of:

openssl version

OpenSSL and similar programs are not very intuitive to start with, and behavior of some commands has changed across releases. Some versions will accept a combined chain for -untrusted, others require multiple arguments for single certificates. E.g.:

openssl verify -purpose sslserver -untrusted combined_chain.pem cert.pem

openssl verify -purpose sslserver -untrusted chain_1.pem -untrusted chain_0.pem cert.pem
9 Likes

For sure !

Just for fun I looked at the openssl changelog and it says -untrusted support for a set of certs was done at the same time as -purpose was introduced (between 0.94 and 0.95). The current docs say the -untrusted file can have one or more certs and be set multiple times.

Two new options to the verify program: -untrusted allows a set of untrusted certificates to be passed in and -purpose which sets the intended purpose of the certificate. If a purpose is set then the new chain verify code is used to check extension consistency.

9 Likes
# openssl version
OpenSSL 1.0.2k-fips  26 Jan 2017

Running the commands you shared

# openssl verify -purpose sslserver -untrusted fullchain.crt 1-server.crt
1-server.crt: C = US, O = Internet Security Research Group, CN = ISRG Root X1
error 2 at 2 depth lookup:unable to get issuer certificate
# openssl verify -purpose sslserver -untrusted 3-root.crt -untrusted 2-inter.crt 1-server.crt
1-server.crt: C = US, O = Internet Security Research Group, CN = ISRG Root X1
error 2 at 2 depth lookup:unable to get issuer certificate

Just to confirm
1-server.crt = Is just the actual certificate ( ====Common Name=illumio.consulting)
2-inter.crt = Is the intermediate cert (Let's encrypt ====Common Name=R3)
3-root.crt = Is the root cert ( ====Common Name=ISRG Root X1)

fullchain.crt is the regular bundle that has all three the above in one file

Ah, you have 1.02.

You should upgrade if possible. That particular version is problematic.

See if any of this works: Old Let’s Encrypt Root Certificate Expiration and OpenSSL 1.0.2 - OpenSSL Blog

9 Likes

I don't have the ability to spin up legacy OS builds right now, but I am fairly certain I had issues with -untrusted on some .98 and 1.02 versions; I don't remember the minor/letter version. Looking at my notes, it appears to have been when I was running OSX 10.10 and 10.11 and using the stock OpenSSL. (I did not write which OpenSSL version was affected in my notes)

I only started using -purpose sslserver recently, thanks to someone posting about it here!

9 Likes

Can you upload the contents of that file (or show it)? The current default LE chain would have 2 certs in the intermediate chain. As long as there is no string in it saying "PRIVATE" it is ok to post.

The root is used by clients to validate that the leaf and intermediates they received chain to something they trust. Where did you get that? It is not sent out by the server - each client already has ones that they trust.

And, just for clarity ... I am using an AWS Linux2 test server which is a close cousin of your CentOS 7. I have the same major version of openssl as you as well as cert store. openssl gets security backports but not features so what works on my test system should be working on yours.

9 Likes

Sure.

Here

1-server.crt

-----BEGIN CERTIFICATE-----
MIIFQDCCBCigAwIBAgISA5MpHDgcI0KAVMZQqa+PKDX2MA0GCSqGSIb3DQEBCwUA
MDIxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQD
EwJSMzAeFw0yMjA3MDYwMDI1MjdaF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myv4Q6W+CyBFC
Dfvp7OOGAN6dEOM4+qR9sdjoSYKEBpsr6GtPAQw4dy753ec5
-----END CERTIFICATE-----

Thanks for the help!

Thanks. That "root" is not really a CA root. Your inter and root files are the two parts of the default "long intermediate" chain returned by Let's Encrypt. At least I am no longer confused by that name :slight_smile:

Good news is your server (leaf) cert with that inter verifies fine on my system.

We should check if you have something odd in your CA store. What does this show:

sudo cat /etc/ssl/certs/ca-bundle.crt | grep -Ei 'ISRG|DST|R3' | grep -e '#'
11 Likes

@MikeMcQ sorry about the confusion with the naming.

Here I just renamed all the files to the default to make things easier.

ls -l
total 20
-rw-r--r--. 1 root root 1882 Jul 6 17:43 cert.pem
-rw-r--r--. 1 root root 3748 Jul 6 17:43 chain.pem
-rw-r--r--. 1 root root 5631 Jul 6 17:43 fullchain.pem
-rw-r--r--. 1 root root 1703 Jul 6 17:43 privkey.pem

I just reset the CentOS7 machine as well

  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-1160.71.1.el7.x86_64

# openssl version
OpenSSL 1.0.2k-fips  26 Jan 2017

Running the command you shared:

sudo cat /etc/ssl/certs/ca-bundle.crt | grep -Ei 'ISRG|DST|R3' | grep -e '#'
# GTS Root R3
# GlobalSign Root CA - R3
# ISRG Root X1

I ran the previous commands as well from @jvanasco

# openssl verify -purpose sslserver -untrusted fullchain.pem cert.pem
cert.pem: OK

# openssl verify -purpose sslserver -untrusted chain.pem cert.pem
cert.pem: OK

# openssl verify -purpose sslserver -untrusted fullchain.pem chain.pem cert.pem
chain.pem: OK
cert.pem: OK

I think we are making some good progress as there was something wrong with the CentOS 7. I still working on the setup and will test soon with the web server itself.

Thanks guys for the help so far.

3 Likes

Excellent. That's what I see on my system too. Let us know what happens with your server config. Cheers

5 Likes