Hi,
We are implementing multi-layer support for our openssl-based PKI solution and
had the following query:
Currently our PKI solution supports only single layer CA support and we use
SSL_CTX_load_verify_locations API with the CAFile option, meaning that the
service loads the CA certificate from a PEM file.
When testing multi-layer support between a client-server model with SSL_VERIFY_PEER
set to true, we observed that using
the CAFile(with all CA certificates- root + intermediate concatenated into a
single PEM file) does not work anymore. But using CAPath option (storing each
CA in separate file, creating hashes for them in a directory and providing that
directory in CAPath) seems to work fine. Is this a known bug with openSSL or is
it something that we are doing wrong.
Also, from the openSSL community perspective, is it advisable to use CAFile
option or CAPath option when providing multi-layer support?
Regds,
Ashok
>>>chain_file or SSL_CTX_add_extra_chain_cert .
> From: Ashok C [mailto:ash...@gmail.com]
> Sent: Friday, 02 December, 2011 00:11
> Keeping the things you have mentioned in mind, this is how it goes.
> In server side, EE key is loaded using
> SSL_CTX_use_RSAPrivateKey_file(ctx,eekeyfile,SSL_FILETYPE_PEM);
> EE certificate is loaded using SSL_CTX_use_certificate_file(ctx,
> eepemfile,SSL_FILETYPE_PEM);
> And the intermediate certificate chain is loaded using
> SSL_CTX_use_certificate_chain_file(ctx, interchain) - This chain
> contains intermediate CA certs without the rootCA.
> In client side, rootCA is loaded using
> SSL_CTX_load_verify_locations(ctx,capemfile,NULL).
> After attempting SSL_connect from client, the intermediate
certificate
> chain and the EE certificate are received in client side using
> SSL_get_peer_cert_chain(ssl) and SSL_get_peer_certificate (ssl)
respectively.
> After this we call SSL_get_verify_result(ssl) which fails.
> So question here is that whether we need to add the received
> chain explicitly to the verify locations in client side? Meaning,
> do we need to build the chain from client side explicitly by ourselves?
First, I made a mistake; it's been a long time since I coded this.
CTX_use_certificate_chain_file loads BOTH the entity cert (which
must be first in the file) AND the chain certs, and thus REPLACES
CTX_use_certificate_file. I'm guessing you have that data,
since if _use_certificate_chain_ doesn't contain the EE cert
then handshake can't select this auth type (and we have no other)
which produces a rather different (and less helpful!) error.
But even with that done/fixed in my test environment I DO get
verify error 24 invalid CA cert depth 1 (my only intermediate).
Is that what you're getting? If so, it looks like maybe the
'purpose' checks have been made stricter since the last time
I did this in test, where I have V1/noextension certs.
I can't set up a test with real(er) (CA)certs immediately.
If you have V1 or otherwise 'substandard' CA certs, you might
try enhancing those.
These specific checks appear to be bypassed for certs in the
truststore, so putting all of the chain above the server EE
in the client truststore is an alternative (and works for me).
In that case the server only needs to send its EE cert (i.e.
only _use_certificate). This is typically more work to set up
and manage 'in the wild', but it is an alternative.