Patchwork Send whole certificate chain from file

login
register
mail settings
Submitter Maciej Szmigiero
Date Nov. 15, 2011, 1:03 a.m.
Message ID <4EC1BA57.3080900@o2.pl>
Download mbox | patch
Permalink /patch/125651/
State Accepted
Commit 65897747469537db3ef316174ab082f3aeae5cbd
Headers show

Comments

Maciej Szmigiero - Nov. 15, 2011, 1:03 a.m.
Currently OpenSSL implementation of TLS in hostapd loads only top
certificate in server certificate file.

This requires any intermediate certs to be installed on client
machine in order it to be able to verify server cert properly and
violates TLS specs (section 7.4.2) when used with such intermediate certs.

In contrast, the GnuTLS implementation correctly loads the whole
chain if it's present in server certificate file.

This patch tries to load whole chain first in OpenSSL implementation,
then reverts to old behavior if it fails.

Signed-off-by: Maciej Szmigiero <mhej@o2.pl>
Jouni Malinen - Nov. 19, 2011, 10:11 a.m.
On Tue, Nov 15, 2011 at 02:03:19AM +0100, Maciej Szmigiero wrote:
> Currently OpenSSL implementation of TLS in hostapd loads only top
> certificate in server certificate file.
> 
> This requires any intermediate certs to be installed on client
> machine in order it to be able to verify server cert properly and
> violates TLS specs (section 7.4.2) when used with such intermediate certs.
> 
> In contrast, the GnuTLS implementation correctly loads the whole
> chain if it's present in server certificate file.

Well, I don't think I would fully agree with these comments since the
expected hostapd configuration would have specified the CA certificates
in the ca_cert file, not in server_cert and that would include the
intermediate CA certificates in the TLS handshake.

> This patch tries to load whole chain first in OpenSSL implementation,
> then reverts to old behavior if it fails.

Anyway, this looks like a reasonable change to add an option of
configuring the intermediate CA certificates in the chain without
explicitly marking them trusted, so applied this.
Maciej Szmigiero - Nov. 19, 2011, 11:29 p.m.
W dniu 19.11.2011 11:11, Jouni Malinen pisze:
> On Tue, Nov 15, 2011 at 02:03:19AM +0100, Maciej Szmigiero wrote:
>> Currently OpenSSL implementation of TLS in hostapd loads only top
>> certificate in server certificate file.
>>
>> This requires any intermediate certs to be installed on client
>> machine in order it to be able to verify server cert properly and
>> violates TLS specs (section 7.4.2) when used with such intermediate certs.
>>
>> In contrast, the GnuTLS implementation correctly loads the whole
>> chain if it's present in server certificate file.
> 
> Well, I don't think I would fully agree with these comments since the
> expected hostapd configuration would have specified the CA certificates
> in the ca_cert file, not in server_cert and that would include the
> intermediate CA certificates in the TLS handshake.

I should have clarified there that I meant the situation
where CAs for clients and servers are different and the one
for servers should not be accepted as client cert issuer.
I know it could be done with TLS cert extensions but I don't know
if OpenSSL actually uses them.

> Anyway, this looks like a reasonable change to add an option of
> configuring the intermediate CA certificates in the chain without
> explicitly marking them trusted, so applied this.
> 

Thank you very much!

Best regards,
Maciej Szmigiero

Patch

--- src/crypto/tls_openssl.c.old        2010-09-07 17:43:39.000000000 +0200
+++ src/crypto/tls_openssl.c    2011-04-12 14:45:24.968047291 +0200
@@ -1586,6 +1586,7 @@ 

     if (SSL_CTX_use_certificate_file(ssl_ctx, client_cert,
                          SSL_FILETYPE_ASN1) != 1 &&
+        SSL_CTX_use_certificate_chain_file(ssl_ctx, client_cert) != 1 &&
         SSL_CTX_use_certificate_file(ssl_ctx, client_cert,
                          SSL_FILETYPE_PEM) != 1) {
        tls_show_errors(MSG_INFO, __func__,