I have three certificates in a chain:
When I examine them using
openssl x509 -in [filename] -text -noout they look fine, root.pem looks like it is self-signed (Issuer == Subject), and the Subject of each certificate is the Issuer of the next one, as expected.
And indeed I can verify the chain up to the intermediate certificate:
$ openssl verify -CAfile root.pem root.pem
$ openssl verify -CAfile root.pem intermediate.pem
However, john.pem fails:
$ openssl verify -CAfile root.pem -CAfile intermediate.pem john.pem
john.pem: C = CL, [...redacted data...]
error 2 at 1 depth lookup:unable to get issuer certificate
To the best of my knowledge, this means that openssl is unable to find the issuer for intermediate.pem. Which doesn't make sense since root.pem is indeed the issuer for intermediate.pem.
What am I missing?
Edit: I had originally posted an answer saying that root.pem and intermediate.pem should be concatenated in one file, and then one should use this file as the parameter for
-CAfile. This is WRONG, because this implicitly trusts intermediate.pem, as Johannes Pille points out. Read the link he posted in my deleted answer: https://mail.python.org/pipermail/cryptography-dev/2016-August/000676.html