Hi Corey, I believe Victor has explained the issue sufficiently (thanks!). Just for completeness here are the actual root certificates relevant to the question. They are part of the German national Smart Metering environment: SM-Test-Root-CA SN1 (O=SM-Test-PKI) CN=SM-Test-Root.CA, SERIALNUMBER=1, gültig bis 19.05.2023 https://www.telesec.de/assets/downloads/Smart-Metering-PKI/sm-test-root.ca_sn1.der SM-Test-Root-CA Link-Zertifikat (1>2) Download CN=SM-Test-Root.CA, SERIALNUMBER=2, gültig bis 19.05.2023 SHA256: ED 54 7F 5D F0 BC 41 D9 D7 3D 92 8B 75 FE 7D B9 9C D9 23 31 78 95 BD 26 BF D2 4A AF DE EF AE 10 https://www.telesec.de/assets/downloads/Smart-Metering-PKI/sm-test-root.ca_sn2_link.der SM-Test-Root-CA SN2 Download CN=SM-Test-Root.CA, SERIALNUMBER=2, gültig bis 19.10.2025 SHA256: 1D 77 21 17 16 69 66 41 AA B2 A3 61 5F E7 8E 76 73 C9 0E 16 E0 69 66 71 47 0F A4 6A 74 FC 18 36 https://www.telesec.de/assets/downloads/Smart-Metering-PKI/sm-test-root.ca_sn2.der (All from https://www.telesec.de/de/service/downloads/branchen-und-eco-systeme/. There is an English language downloads page but that does not show the Smart Metering PKI section.) Our intermediate CA that issued the end entity certificate is http://sm-pkitest.atos.net/cert/Atos-Smart-Grid-Test.CA.3.crt Fingerprint 14 f3 d2 f8 cd 00 ca 9d f6 41 ca 5b 10 55 9c d3 ac eb cc 5a The chain Atos-Smart-Grid-Test.CA.3.crt <- sm-test-root.ca_sn2.der is fine. It is a straightforward self-signed root plus intermediate setup. The chain Atos-Smart-Grid-Test.CA.3.crt <- sm-test-root.ca_sn2_link.der <- sm-test-root.ca_sn1.der is problematic because the “link” certificate has SN2 as subject but SN1 as issuer. So I believe it is effectively adding another intermediate layer which then violates pathlen:1 in sm-test-root.ca_sn1.der. My (naïve) understanding of such link or cross-certified CA certificates is that they are intended to help systems that only have SN1 as a trust anchor to verify certificates issued by SN2. But wouldn’t they stumble over pathlen too? My colleague doing the verifying initially had all three sm-test-root.ca certificates in his CAfile and OpenSSL 1.1.1 picked the path with the link certificate. Once he removed that everything was fine as the verify then used the self-signed SN2 root directly. Regards, Andrew. Von: Corey Bonnell <Corey.Bonnell@xxxxxxxxxxxx> Hi Andrew, Can you provide the actual subject DNs for each certificate? RFC 5280 specifies that self-issued certificates (i.e., issuer DN == subject DN) are not considered in the pathLen calculation, so knowing whether these certificates are self-issued or not may be helpful in better diagnosing the issue. Thanks, Corey From: openssl-users <openssl-users-bounces@xxxxxxxxxxx> On Behalf Of Andrew Lynch via openssl-users So is this a possible bug or a feature of OpenSSL 1.1.1? (using 1.1.1n right now) If I set up the content of CAfile or CApath so that E <- D <- C <- A is the only path that can be taken then the validation fails with error 25 at 3 depth lookup: path length constraint exceeded If I create the first root certificate (A) with pathlen:2 instead of pathlen:1 then validation succeeds user1_cert.pem: OK Chain: depth=0: C = DE, O = Test Org, CN = Test User (untrusted) E depth=1: C = DE, O = Test Org, CN = Test Sub-CA D depth=2: C = DE, O = Test Org, CN = Test Root 2-CA C depth=3: C = DE, O = Test Org, CN = Test Root 1-CA A So it appears to me that OpenSSL 1.1.1n is definitely taking the pathlen constraint of certificate A into account. Andrew. Von: Erwann Abalea <erwann.abalea@xxxxxxxxxxxx> Assuming that all self-signed certificates are trusted (here, A and B), then providing a CAfile with D+C+B+A to validate E, the different possible paths are: - E <- D <- B: this path is valid - E <- D <- C <- A: this path is valid In the validation algorithm described in RFC5280 and X.509, the pathlenConstraints contained in the certificate of the Trust Anchor (here, A or B) is not taken into account. Therefore, the only ones that matter are the values set in C and D, and these values are coherent with both chains. On Thu, Sep 15, 2022 at 7:34 PM Andrew Lynch via openssl-users <openssl-users@xxxxxxxxxxx> wrote:
-- Cordialement, Erwann Abalea. |
Attachment:
smime.p7s
Description: S/MIME cryptographic signature