summaryrefslogtreecommitdiff
path: root/lib/libssl
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2020-05-23 12:14:53 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2020-05-23 12:14:53 +0000
commit94daf7f378211abe1442ada5fa801c5aacaae50b (patch)
tree0fd359f9a00db428868f2f30e8248fef1c900284 /lib/libssl
parent7021a67826f1886f6384ee99d541aab32377122b (diff)
Enable SSL_MODE_AUTO_RETRY by default.
In TLSv1.2 and earlier, when an application goes to read application data, handshake messages may be received instead, when the peer has triggered renegotation. A similar thing occurs in TLSv1.3 when key updates are triggered or the server sends new session tickets. Due to the SSL_read() API there is no way to indicate that we got no application data, instead after processing the in-band handshake messages it would be normal to return SSL_ERROR_WANT_READ and have the caller call SSL_read() again. However, various applications expect SSL_read() to return with either application data or a fatal error, when used on a blocking socket. These applications do not play well with TLSv1.3 post-handshake handshake messages (PHH), as they fail to handle SSL_ERROR_WANT_READ. The same code is also broken in the case of a TLSv1.2 or older renegotiation, however these are less likely to be encountered. Such code should set SSL_MODE_AUTO_RETRY in order to avoid these issues. Contrary to the naming, SSL_MODE_AUTO_RETRY does not actually retry in every case - it retries following handshake messages in the application data stream (i.e. renegotiation and PHH messages). This works around the unretried SSL_read() on a blocking socket case, however in the case where poll/select is used with blocking sockets, the retry will likely result in the read blocking after the handshake messages are processed. Rather than pushing for broken code to be fixed, OpenSSL decided to enable SSL_MODE_AUTO_RETRY by default, instead breaking code that does poll or select on blocking sockets (like s_client and s_server). Unfortunately we get to follow suit. ok beck@ inoguchi@ tb@
Diffstat (limited to 'lib/libssl')
-rw-r--r--lib/libssl/ssl_lib.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/libssl/ssl_lib.c b/lib/libssl/ssl_lib.c
index acb34e28af6..6ef2083f528 100644
--- a/lib/libssl/ssl_lib.c
+++ b/lib/libssl/ssl_lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssl_lib.c,v 1.216 2020/05/23 11:30:12 tb Exp $ */
+/* $OpenBSD: ssl_lib.c,v 1.217 2020/05/23 12:14:52 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -1743,6 +1743,7 @@ SSL_CTX_new(const SSL_METHOD *meth)
ret->method = meth;
ret->internal->min_version = meth->internal->min_version;
ret->internal->max_version = meth->internal->max_version;
+ ret->internal->mode = SSL_MODE_AUTO_RETRY;
ret->cert_store = NULL;
ret->internal->session_cache_mode = SSL_SESS_CACHE_SERVER;