<div dir="ltr"><div dir="ltr"><div dir="ltr" class="gmail_signature"><div dir="ltr" class="gmail_signature">Hi,</div><div dir="ltr" class="gmail_signature"><br></div><div dir="ltr" class="gmail_signature">I'm really struggling to get my head around a specific scenario that isn't behaving as I expect.  Hopefully someone with more experience/knowledge can set me on the right path.</div><div dir="ltr" class="gmail_signature"><br></div><div dir="ltr" class="gmail_signature">Note - my attempts to reproduce this in a lab have been unsuccessful, although I don't have access to the server private key, so the attempts have been with a completely independent CA chain.</div><div dir="ltr" class="gmail_signature"><br></div><div dir="ltr" class="gmail_signature"><br></div><div dir="ltr" class="gmail_signature">I have a private CA, which has signed an intermediate certificate which has signed a server certificate for an internal web server which is used by various automated systems (all linux based).</div><div dir="ltr" class="gmail_signature"><br></div><div dir="ltr" class="gmail_signature">The webserver (Apache) has the server cert and key, defined and in use as well as the intermediate certificate defined as the chain certificate - this all shows as expected.</div><div dir="ltr" class="gmail_signature"><br></div><div dir="ltr" class="gmail_signature">I have then added the root certificate to the trusted certs for an automated system (populated `/etc/pki/ca-trust/source/anchors/` run `update-ca-trust extract`).</div><div dir="ltr" class="gmail_signature"><br></div><div dir="ltr" class="gmail_signature">After this curl no longer complains about the certificate from the web server (expected).</div><div dir="ltr" class="gmail_signature">However OpenSSL still does (unexpected), and I presume that for the same reason(s) urllib in Python also doesn't accept the certificate.</div><div dir="ltr" class="gmail_signature">If I manually feed `openssl verify` the certificates and chain then they all come back "OK".</div><div dir="ltr" class="gmail_signature"><br></div><div dir="ltr" class="gmail_signature">I've set up these systems a number of times with both self signed and CA signed certs and never seen this behaviour.</div><div dir="ltr" class="gmail_signature"><br></div><div dir="ltr" class="gmail_signature">I'm slightly at a loss as to what diagnostics I even need at this point... so I've dropped a summary of relevant(?) diagnostics at this point below.</div><div dir="ltr" class="gmail_signature"><br></div><div dir="ltr" class="gmail_signature">Thanks,</div><div dir="ltr" class="gmail_signature"><br></div><div dir="ltr" class="gmail_signature"><br></div><div dir="ltr" class="gmail_signature">John</div><div dir="ltr" class="gmail_signature"><br></div><div dir="ltr" class="gmail_signature">-- </div><div dir="ltr" class="gmail_signature"><br></div><div dir="ltr" class="gmail_signature"># Check that the root is installed into the trusted bundle:</div><div dir="ltr" class="gmail_signature"># awk -v cmd='openssl x509 -noout -subject -serial -fingerprint; echo' '/BEGIN/{close(cmd)};{print | cmd}' < /etc/ssl/certs/ca-bundle.trust.crt | grep -A1 CAROOT</div><div dir="ltr" class="gmail_signature">subject= /CN=CAROOT/O=org/C=XX</div><div dir="ltr" class="gmail_signature">serial=4D4C00241A7A17D0</div><div dir="ltr" class="gmail_signature"><br></div><div dir="ltr" class="gmail_signature"># Check that the pem file I have is correct (serial matches above):</div><div dir="ltr" class="gmail_signature"># openssl x509 -in CAROOT.pem -text | grep erial</div><div dir="ltr" class="gmail_signature">        Serial Number: 5569826994213492688 (0x4d4c00241a7a17d0)</div><div dir="ltr" class="gmail_signature"><br></div><div dir="ltr" class="gmail_signature"># Check that the chain is contiguous:</div><div dir="ltr" class="gmail_signature"># openssl x509 -text -noout -in CAROOT.pem | grep -A1 -e Ident -e erial</div><div dir="ltr" class="gmail_signature">        Serial Number: 5569826994213492688 (0x4d4c00241a7a17d0)</div><div dir="ltr" class="gmail_signature">    Signature Algorithm: sha256WithRSAEncryption</div><div dir="ltr" class="gmail_signature">            X509v3 Subject Key Identifier:</div><div dir="ltr" class="gmail_signature">                2A:3E:33:88:7E:19:35:7C:6E:9D:7C:63:90:80:B8:DF:96:5A:A8:9D</div><div dir="ltr" class="gmail_signature">            X509v3 Authority Key Identifier:</div><div dir="ltr" class="gmail_signature">                keyid:2A:3E:33:88:7E:19:35:7C:6E:9D:7C:63:90:80:B8:DF:96:5A:A8:9D</div><div dir="ltr" class="gmail_signature"># openssl x509 -text -noout -in CAINTER.pem | grep -A1 -e Ident</div><div dir="ltr" class="gmail_signature">            X509v3 Subject Key Identifier:</div><div dir="ltr" class="gmail_signature">                FB:17:C5:BB:BD:AD:84:65:4F:16:A7:E8:FA:95:1D:C7:D9:29:45:6A</div><div dir="ltr" class="gmail_signature">            X509v3 Authority Key Identifier:</div><div dir="ltr" class="gmail_signature">                keyid:2A:3E:33:88:7E:19:35:7C:6E:9D:7C:63:90:80:B8:DF:96:5A:A8:9D</div><div dir="ltr" class="gmail_signature"># openssl x509 -text -noout -in SERVER.pem | grep -A1 -e Ident</div><div dir="ltr" class="gmail_signature">            X509v3 Subject Key Identifier:</div><div dir="ltr" class="gmail_signature">                F5:26:E2:09:A4:41:EC:EE:75:E2:4E:E4:02:90:B7:CD:EB:FC:4E:EC</div><div dir="ltr" class="gmail_signature">            X509v3 Authority Key Identifier:</div><div dir="ltr" class="gmail_signature">                keyid:FB:17:C5:BB:BD:AD:84:65:4F:16:A7:E8:FA:95:1D:C7:D9:29:45:6A</div><div dir="ltr" class="gmail_signature"><br></div><div dir="ltr" class="gmail_signature">To my eye those all look lined up, and the serial on the root still agrees.</div><div dir="ltr" class="gmail_signature"><span class="gmail-Apple-tab-span" style="white-space:pre">           </span>  </div><div dir="ltr" class="gmail_signature"><span class="gmail-Apple-tab-span" style="white-space:pre">              </span>  </div><div dir="ltr" class="gmail_signature">CURL:</div><div dir="ltr" class="gmail_signature"># curl <a href="https://server.fqdn">https://server.fqdn</a></div><div dir="ltr" class="gmail_signature"><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"></div><div dir="ltr" class="gmail_signature"><html><head></div><div dir="ltr" class="gmail_signature"><title>302 Found</title></div><div dir="ltr" class="gmail_signature"></head><body></div><div dir="ltr" class="gmail_signature"><h1>Found</h1></div><div dir="ltr" class="gmail_signature"><p>The document has moved <a href="<a href="https://server.fqdn:443/path/">https://server.fqdn:443/path/</a>">here</a>.</p></div><div dir="ltr" class="gmail_signature"></body></html></div><div dir="ltr" class="gmail_signature"><br></div><div dir="ltr" class="gmail_signature">OpenSSL:</div><div dir="ltr" class="gmail_signature"># openssl s_client -connect server.fqdn:443</div><div dir="ltr" class="gmail_signature">CONNECTED(00000007)</div><div dir="ltr" class="gmail_signature">depth=1 CN = CAINTER, O = org, C = XX</div><div dir="ltr" class="gmail_signature">verify error:num=2:unable to get issuer certificate</div><div dir="ltr" class="gmail_signature">issuer= CN = CAROOT, O = org, C = XX</div><div dir="ltr" class="gmail_signature"> --8<--</div><div dir="ltr" class="gmail_signature">Verify return code: 2 (unable to get issuer certificate)</div><div dir="ltr" class="gmail_signature"><br></div></div></div></div>