[MDEV-10803] connection timeout doesn't work for SSL connections Created: 2016-09-13  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: SSL
Affects Version/s: 10.0, 10.1, 10.3.4, 10.2.13
Fix Version/s: 10.4

Type: Bug Priority: Major
Reporter: Georg Richter Assignee: Sergei Golubchik
Resolution: Unresolved Votes: 0
Labels: upstream-fixed

Issue Links:
Relates
relates to MDEV-15341 Disable TLS session tickets Closed
Sprint: 10.3.6-1

 Description   

Specifying a connection timeout for a TLS/SSL connection has no effect. Instead of applying connect_timeout for handshake ssl_do function sets timeout for session:

static int ssl_do(struct st_VioSSLFd *ptr, Vio *vio, long timeout,
                  ssl_handshake_func_t func, unsigned long *errptr)
{
 .....
  SSL_SESSION_set_timeout(SSL_get_session(ssl), timeout);
}

The SSL_SESSION_set_timeout is used for setting session timeout values which are linked to SSL resumption. They have nothing to do with timing out a connection. As a bad side effect the session hit rate goes down, especially when specifying a low connection timeout value.

Howto fix:
Check return codes of SSL_connect() function: In case of SSL_ERROR_WANT_READ/ SSL_ERROR_WANT_WRITE loop until handshake finished or connection timeout passed.



 Comments   
Comment by Elena Stepanova [ 2016-09-19 ]

There is also bug MDEV-7111 which might be somehow related (or not).

Comment by Sergei Golubchik [ 2017-05-19 ]

In my tests, connect timeout worked with ssl. I set it on the server and made the client to wait inside SSL_connect on a breakpoint. It timed out as expected.

Comment by Georg Richter [ 2018-03-05 ]

Serg: As described above, the SSL_SESSION_set_timeout() call is useless.
Please also note, that a NULL ptr is passed, since SSL_get_session(ssl) returns NULL, since a session cannot be obtained before handshake completed.

Comment by Sergei Golubchik [ 2019-04-25 ]

MySQL Bug#27655457, commit e806d29d100e7cfc0d16661e508df81ecf25c802

Generated at Thu Feb 08 07:45:02 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.