X509Chain.Build() fails to return valid certificate chain on Linux (openssl) if CA store contains expired certificate for CA, even if store contains valid cross-signed certificate for the same CA #43884
Labels
Milestone
Description
Found when trying to reproduce #43879 on Linux.
There used to be a bug in OpenSSL where
X509_verify_cert()
could fail to find a valid certificate chain if the CA store contained multiple certificates for the same CA subject name, and one of the certificates had expired. However, that has been fixed long ago. It seems, though, that (a variant of?) this problem might exist in .NET.I've written a stand-alone test application that generates the following certificates:
and installs the certificates in the CA store, and tries to build a certificate chain from the end-entity certificate. Ideally, I would have liked the scenario to be slightly different (letting an expiring intermediate be available as a new root CA certificate), but openssl would prefer the shorter certificate chain, so the right code paths would not be triggered to reproduce this issue.
Expand to see test code included below:
The test application produces the following output:
The test application also dumps the generated CA certificates and end-entity certificate to two files
sslCerts.pem
andendEntity.pem
. Runningopenssl verify
with those files gives us the following:In other words,
openssl verify
is able to resolve the right certificate chain, whereas .NET using openssl is not.Configuration
Seen on .NET Core 3.1.8 on Linux, using
OpenSSL 1.1.1f 31 Mar 2020
.The text was updated successfully, but these errors were encountered: