Bug 62691 - OpenSSL 1.1.1 and client-certificate renegotiation causes 1 minute delay
Summary: OpenSSL 1.1.1 and client-certificate renegotiation causes 1 minute delay
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_ssl (show other bugs)
Version: 2.4.34
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-09-07 13:13 UTC by William Perry
Modified: 2018-09-25 20:19 UTC (History)
0 users



Attachments
Trace5 logs of the renegotiation (9.16 KB, text/plain)
2018-09-23 23:02 UTC, William Perry
Details

Note You need to log in before you can comment on or make changes to this bug.
Description William Perry 2018-09-07 13:13:11 UTC
Working on a project and need an LTS version of OpenSSL, which is soon to be 1.1.1.  Recompiled apache 2.4.34 against it and trying to use client certificates shows a 1 minute delay between the handshake completing and the 0-byte SSL_peek() returning in ssl_engine_kernel.c:1033 returns.

Working just fine with OpenSSL 1.1.0 or 1.0.2, also appears to work without a delay using the 1.1.1 openssl s_server command.

Minimal configuration file is:

------------
LoadModule ssl_module		/usr/lib/apache2/modules/mod_ssl.so
LoadModule mpm_event_module	/usr/lib/apache2/modules/mod_mpm_event.so
LoadModule unixd_module		/usr/lib/apache2/modules/mod_unixd.so
LoadModule mime_module		/usr/lib/apache2/modules/mod_mime.so
LoadModule authz_core_module	/usr/lib/apache2/modules/mod_authz_core.so

SSLPassPhraseDialog "exec:......"

LogLevel trace5
ErrorLog /tmp/client-certificates.log
ServerName my.test.com
DocumentRoot /var/www

<Location />
   SSLVerifyClient require
   Require ssl-verify-client
</Location>

Listen 1443
<VirtualHost *:1443>
    SSLEngine on
    SSLCertificateKeyFile "/etc/xxxx.key"
    SSLCertificateFile "/etc/xxxx.cert"
    SSLCertificateChainFile "/etc/xxxx.cert"
    SSLCACertificateFile "/etc/backendca.cert"
</VirtualHost>
------------

The logs from apache itself that shows the delay are:

[Tue Sep 04 18:58:14.886205 2018] [ssl:debug] [pid 2571:tid 140532252661504] ssl_engine_kernel.c(2082): [client 172.16.1.101:53414] AH02041: Protocol: TLSv1.2, Cipher: ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits) 
---- delay here ---- 
[Tue Sep 04 18:59:14.944591 2018] [ssl:trace4] [pid 2571:tid 140532252661504] ssl_engine_io.c(2204): [client 172.16.1.101:53414] OpenSSL: read 0/5 bytes from BIO#7fd014002a10 [mem: 7fd014002d43] (BIO dump follows)

There is no delay before the web browser / client prompts for a certificate to use - just between the ssl re-handshake completing and the peek() returning no bytes.
Comment 1 Stefan Eissing 2018-09-13 11:48:51 UTC
We are currently adding support for TLSv1.3 for the next 2.4.x release. If you like, you can test your setup against

https://svn.apache.org/repos/asf/httpd/httpd/branches/tlsv1.3-for-2.4.x

to see if this delay has been eliminated by the recent changes in renegotiation/client cert handling. Would be good to know. Thanks!
Comment 2 William Perry 2018-09-23 23:02:07 UTC
Created attachment 36161 [details]
Trace5 logs of the renegotiation

I downloaded the latest on that branch as of a few days ago (, and the behaviour is still the same.  Full renegotiation is done, certificate is verified, and then a timeout of 1 minute while the SSL_peek() fails.  Attaching logs @ trace5
Comment 3 William Perry 2018-09-23 23:03:07 UTC
Status back to 'new' - please let me know if you need any additional info.
Comment 4 Rainer Jung 2018-09-24 08:05:23 UTC
Thanks for the logs. I can't currently promise to work on it myself, but some info:

- the branch tlsv1.3-for-2.4.x has been merged just 3 days ago into the normal 2.4.x branch. So any further tests can be done against the normal branch, unless something needs to get tested which might only exist in trunk, in which case that would b the right source. The tlsv1.3-for-2.4.x should probably considered stale starting now.

- what was the client you tested with?

- just to make sure: the hang only happens when "RE"negotation occurs due to the VHost having different TLS config than the URI on that VHost that you are trying to access (eg. the access to the VHost is not protected by client certs, but some URLs are). To phrase it differently: when all of the vhost uses the same ssl config including client certs, ciphers etc., then no hang occurs?

- As far as I understand this situation, previously handled by renegotiation, gets handled in OpenSSL 1.1.1 by a post-handshake-authentication (PHA) extension and support for PHA is not yet clear for all clients. Especially clients using OpenSSL as their client TLS stack need to explicitly turn on PHA when using OpenSSL 1.1.1. But that's only what I think I understood from other discussions.

Thanks and regards,

Rainer
Comment 5 William Perry 2018-09-24 12:51:26 UTC
Moving "SSLVerifyClient require" outside of the <Location> block instantly returns the document.  So it does appear to be ONLY the renegotiation case.
Comment 6 Joe Orton 2018-09-25 11:34:32 UTC
Note this is testing with TLSv1.2 not 1.3 - I will try to reproduce as well.

Can you stick "#warning foo" on a line directly before:

    SSL_CTX_clear_mode(ctx, SSL_MODE_AUTO_RETRY);

in ssl_engine_init.c to make sure that is being enabled when you build?  Preferable to test against the 2.4.x branch now.
Comment 7 Joe Orton 2018-09-25 11:43:56 UTC
I can't reproduce with 2.4.34+the TLS v1.3 patch from the branch, linked against Fedora 29's OpenSSL 1.1.1.

Can you also test with the OpenSSL 1.1.1 final release - the original post was dated before 1.1.1 was tagged - so I guess you were you testing with a -pre release?
Comment 8 William Perry 2018-09-25 20:19:15 UTC
Using the released OpenSSL 1.1.1 and the latest from 2.4.x seems to work without any noticeable delay.  Guess this one can go to resolved.

I was using 1.1.1-pre9.  thanks.