diff options
| -rw-r--r-- | src/idevice.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/idevice.c b/src/idevice.c index 91d67e6..a1cc013 100644 --- a/src/idevice.c +++ b/src/idevice.c | |||
| @@ -559,6 +559,7 @@ static void internal_ssl_cleanup(ssl_data_t ssl_data) | |||
| 559 | if (ssl_data->ctx) { | 559 | if (ssl_data->ctx) { |
| 560 | SSL_CTX_free(ssl_data->ctx); | 560 | SSL_CTX_free(ssl_data->ctx); |
| 561 | } | 561 | } |
| 562 | openssl_init_done = 0; | ||
| 562 | #else | 563 | #else |
| 563 | if (ssl_data->session) { | 564 | if (ssl_data->session) { |
| 564 | gnutls_deinit(ssl_data->session); | 565 | gnutls_deinit(ssl_data->session); |
| @@ -667,6 +668,11 @@ idevice_error_t idevice_connection_enable_ssl(idevice_connection_t connection) | |||
| 667 | } | 668 | } |
| 668 | 669 | ||
| 669 | /* Set up OpenSSL */ | 670 | /* Set up OpenSSL */ |
| 671 | if (openssl_init_done == 0) { | ||
| 672 | SSL_library_init(); | ||
| 673 | openssl_init_done = 1; | ||
| 674 | } | ||
| 675 | |||
| 670 | BIO *ssl_bio = BIO_new(BIO_s_socket()); | 676 | BIO *ssl_bio = BIO_new(BIO_s_socket()); |
| 671 | if (!ssl_bio) { | 677 | if (!ssl_bio) { |
| 672 | debug_info("ERROR: Could not create SSL bio."); | 678 | debug_info("ERROR: Could not create SSL bio."); |
| @@ -674,11 +680,12 @@ idevice_error_t idevice_connection_enable_ssl(idevice_connection_t connection) | |||
| 674 | } | 680 | } |
| 675 | BIO_set_fd(ssl_bio, (int)(long)connection->data, BIO_NOCLOSE); | 681 | BIO_set_fd(ssl_bio, (int)(long)connection->data, BIO_NOCLOSE); |
| 676 | 682 | ||
| 677 | if (openssl_init_done == 0) { | ||
| 678 | SSL_library_init(); | ||
| 679 | openssl_init_done = 1; | ||
| 680 | } | ||
| 681 | SSL_CTX *ssl_ctx = SSL_CTX_new(SSLv3_method()); | 683 | SSL_CTX *ssl_ctx = SSL_CTX_new(SSLv3_method()); |
| 684 | if (ssl_ctx == NULL) { | ||
| 685 | debug_info("ERROR: Could not create SSL context."); | ||
| 686 | BIO_free(ssl_bio); | ||
| 687 | return ret; | ||
| 688 | } | ||
| 682 | 689 | ||
| 683 | BIO* membp; | 690 | BIO* membp; |
| 684 | X509* rootCert = NULL; | 691 | X509* rootCert = NULL; |
