diff options
Diffstat (limited to 'src/idevice.c')
| -rw-r--r-- | src/idevice.c | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/src/idevice.c b/src/idevice.c index 6b6a716..10d897f 100644 --- a/src/idevice.c +++ b/src/idevice.c | |||
| @@ -1036,6 +1036,11 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_enable_ssl(idevice_conne | |||
| 1036 | 1036 | ||
| 1037 | LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_disable_ssl(idevice_connection_t connection) | 1037 | LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_disable_ssl(idevice_connection_t connection) |
| 1038 | { | 1038 | { |
| 1039 | return idevice_connection_disable_bypass_ssl(connection, 0); | ||
| 1040 | } | ||
| 1041 | |||
| 1042 | LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_disable_bypass_ssl(idevice_connection_t connection, uint8_t sslBypass) | ||
| 1043 | { | ||
| 1039 | if (!connection) | 1044 | if (!connection) |
| 1040 | return IDEVICE_E_INVALID_ARG; | 1045 | return IDEVICE_E_INVALID_ARG; |
| 1041 | if (!connection->ssl_data) { | 1046 | if (!connection->ssl_data) { |
| @@ -1043,24 +1048,29 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_disable_ssl(idevice_conn | |||
| 1043 | return IDEVICE_E_SUCCESS; | 1048 | return IDEVICE_E_SUCCESS; |
| 1044 | } | 1049 | } |
| 1045 | 1050 | ||
| 1051 | // some services require plain text communication after SSL handshake | ||
| 1052 | // sending out SSL_shutdown will cause bytes | ||
| 1053 | if (!sslBypass) { | ||
| 1046 | #ifdef HAVE_OPENSSL | 1054 | #ifdef HAVE_OPENSSL |
| 1047 | if (connection->ssl_data->session) { | 1055 | if (connection->ssl_data->session) { |
| 1048 | /* see: https://www.openssl.org/docs/ssl/SSL_shutdown.html#RETURN_VALUES */ | 1056 | /* see: https://www.openssl.org/docs/ssl/SSL_shutdown.html#RETURN_VALUES */ |
| 1049 | if (SSL_shutdown(connection->ssl_data->session) == 0) { | 1057 | if (SSL_shutdown(connection->ssl_data->session) == 0) { |
| 1050 | /* Only try bidirectional shutdown if we know it can complete */ | 1058 | /* Only try bidirectional shutdown if we know it can complete */ |
| 1051 | int ssl_error; | 1059 | int ssl_error; |
| 1052 | if ((ssl_error = SSL_get_error(connection->ssl_data->session, 0)) == SSL_ERROR_NONE) { | 1060 | if ((ssl_error = SSL_get_error(connection->ssl_data->session, 0)) == SSL_ERROR_NONE) { |
| 1053 | SSL_shutdown(connection->ssl_data->session); | 1061 | SSL_shutdown(connection->ssl_data->session); |
| 1054 | } else { | 1062 | } else { |
| 1055 | debug_info("Skipping bidirectional SSL shutdown. SSL error code: %i\n", ssl_error); | 1063 | debug_info("Skipping bidirectional SSL shutdown. SSL error code: %i\n", ssl_error); |
| 1064 | } | ||
| 1056 | } | 1065 | } |
| 1057 | } | 1066 | } |
| 1058 | } | ||
| 1059 | #else | 1067 | #else |
| 1060 | if (connection->ssl_data->session) { | 1068 | if (connection->ssl_data->session) { |
| 1061 | gnutls_bye(connection->ssl_data->session, GNUTLS_SHUT_RDWR); | 1069 | gnutls_bye(connection->ssl_data->session, GNUTLS_SHUT_RDWR); |
| 1062 | } | 1070 | } |
| 1063 | #endif | 1071 | #endif |
| 1072 | } | ||
| 1073 | |||
| 1064 | internal_ssl_cleanup(connection->ssl_data); | 1074 | internal_ssl_cleanup(connection->ssl_data); |
| 1065 | free(connection->ssl_data); | 1075 | free(connection->ssl_data); |
| 1066 | connection->ssl_data = NULL; | 1076 | connection->ssl_data = NULL; |
