diff options
author | 2022-01-31 12:06:52 +0800 | |
---|---|---|
committer | 2022-07-03 01:28:00 +0200 | |
commit | 32d531a955b9a099e3418e84ef31f4b041974a4d (patch) | |
tree | 1fe6dd9cb8e702bb5ac4028d3a9a18a7a821d4ec | |
parent | 93c25b7846179c397a5316fb4fecb31ceff0ec2f (diff) | |
download | libimobiledevice-32d531a955b9a099e3418e84ef31f4b041974a4d.tar.gz libimobiledevice-32d531a955b9a099e3418e84ef31f4b041974a4d.tar.bz2 |
idevice: Fix OpenSSL 3.0 internal error on read timeout
-rw-r--r-- | src/idevice.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/idevice.c b/src/idevice.c index 3984583..5930db9 100644 --- a/src/idevice.c +++ b/src/idevice.c | |||
@@ -785,6 +785,10 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_receive_timeout(idevice_ | |||
785 | int sslerr = SSL_get_error(connection->ssl_data->session, r); | 785 | int sslerr = SSL_get_error(connection->ssl_data->session, r); |
786 | if (sslerr == SSL_ERROR_WANT_READ) { | 786 | if (sslerr == SSL_ERROR_WANT_READ) { |
787 | continue; | 787 | continue; |
788 | } else if (sslerr == SSL_ERROR_ZERO_RETURN) { | ||
789 | if (connection->status == IDEVICE_E_TIMEOUT) { | ||
790 | SSL_set_shutdown(connection->ssl_data->session, 0); | ||
791 | } | ||
788 | } | 792 | } |
789 | break; | 793 | break; |
790 | } | 794 | } |
@@ -1203,6 +1207,14 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_enable_ssl(idevice_conne | |||
1203 | SSL_CTX_set_max_proto_version(ssl_ctx, TLS1_VERSION); | 1207 | SSL_CTX_set_max_proto_version(ssl_ctx, TLS1_VERSION); |
1204 | } | 1208 | } |
1205 | #endif | 1209 | #endif |
1210 | #if (OPENSSL_VERSION_MAJOR >= 3) && defined(SSL_OP_IGNORE_UNEXPECTED_EOF) | ||
1211 | /* | ||
1212 | * For OpenSSL 3 and later, mark close_notify alerts as optional. | ||
1213 | * For prior versions of OpenSSL we check for SSL_ERROR_SYSCALL when | ||
1214 | * reading instead (this error changes to SSL_ERROR_SSL in OpenSSL 3). | ||
1215 | */ | ||
1216 | SSL_CTX_set_options(ssl_ctx, SSL_OP_IGNORE_UNEXPECTED_EOF); | ||
1217 | #endif | ||
1206 | 1218 | ||
1207 | BIO* membp; | 1219 | BIO* membp; |
1208 | X509* rootCert = NULL; | 1220 | X509* rootCert = NULL; |