summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikos Mavrogiannopoulos2017-01-02 14:35:39 +0100
committerGravatar Nikias Bassen2017-04-27 14:37:13 +0200
commit0cf6bb6f5bece0885c6e4806b5e62ec4296ab75e (patch)
tree0a72e8aa63bd50ee1032a12330f534e034b18f8a /src
parenta5b2266b4e9c2112f85f94aa1d45440007922e08 (diff)
downloadlibimobiledevice-0cf6bb6f5bece0885c6e4806b5e62ec4296ab75e.tar.gz
libimobiledevice-0cf6bb6f5bece0885c6e4806b5e62ec4296ab75e.tar.bz2
gnutls: check for interrupted gnutls_handshake()
That is, recover if gnutls_handshake() returns with non fatal error codes like GNUTLS_E_INTERRUPTED or GNUTLS_E_AGAIN.
Diffstat (limited to 'src')
-rw-r--r--src/idevice.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/idevice.c b/src/idevice.c
index 89724ff..21b10ba 100644
--- a/src/idevice.c
+++ b/src/idevice.c
@@ -697,7 +697,11 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_enable_ssl(idevice_conne
return IDEVICE_E_INVALID_ARG;
idevice_error_t ret = IDEVICE_E_SSL_ERROR;
+#ifdef HAVE_OPENSSL
uint32_t return_me = 0;
+#else
+ int return_me = 0;
+#endif
plist_t pair_record = NULL;
userpref_read_pair_record(connection->udid, &pair_record);
@@ -817,14 +821,17 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_enable_ssl(idevice_conne
if (errno) {
debug_info("WARNING: errno says %s before handshake!", strerror(errno));
}
- return_me = gnutls_handshake(ssl_data_loc->session);
+
+ do {
+ return_me = gnutls_handshake(ssl_data_loc->session);
+ } while(return_me == GNUTLS_E_AGAIN || return_me == GNUTLS_E_INTERRUPTED);
+
debug_info("GnuTLS handshake done...");
if (return_me != GNUTLS_E_SUCCESS) {
internal_ssl_cleanup(ssl_data_loc);
free(ssl_data_loc);
- debug_info("GnuTLS reported something wrong.");
- gnutls_perror(return_me);
+ debug_info("GnuTLS reported something wrong: %s", gnutls_strerror(return_me));
debug_info("oh.. errno says %s", strerror(errno));
} else {
connection->ssl_data = ssl_data_loc;