From e88fdf99f943c9523ed9f1d30c940804ad99d7de Mon Sep 17 00:00:00 2001 From: Mikkel Kamstrup Erlandsen Date: Fri, 27 Sep 2019 10:18:04 +0200 Subject: idevice: fix hang in SSL_shutdown --- src/idevice.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/idevice.c b/src/idevice.c index fd1f4b5..90b531d 100644 --- a/src/idevice.c +++ b/src/idevice.c @@ -930,7 +930,13 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_disable_ssl(idevice_conn if (connection->ssl_data->session) { /* see: https://www.openssl.org/docs/ssl/SSL_shutdown.html#RETURN_VALUES */ if (SSL_shutdown(connection->ssl_data->session) == 0) { - SSL_shutdown(connection->ssl_data->session); + /* Only try bidirectional shutdown if we know it can complete */ + int ssl_error; + if ((ssl_error = SSL_get_error(connection->ssl_data->session, 0)) == SSL_ERROR_NONE) { + SSL_shutdown(connection->ssl_data->session); + } else { + debug_info("Skipping bidirectional SSL shutdown. SSL error code: %i\n", ssl_error); + } } } #else -- cgit v1.1-32-gdbae