1 From e64a7d229fdcb5c190064b7860ade50124dcc735 Mon Sep 17 00:00:00 2001
2 From: Aurelien David <aurelien.david@telecom-paristech.fr>
3 Date: Fri, 6 Oct 2017 16:46:18 +0200
4 Subject: [PATCH] compatibility with OpenSSL 1.1.x (#616)
7 src/utils/downloader.c | 40 +++++++++++++++++++++++++++++-----------
8 1 file changed, 29 insertions(+), 11 deletions(-)
10 diff --git a/src/utils/downloader.c b/src/utils/downloader.c
11 index b8c923b88..3b7d37b41 100644
12 --- a/src/utils/downloader.c
13 +++ b/src/utils/downloader.c
14 @@ -204,7 +204,7 @@ struct __gf_download_manager
15 u32 limit_data_rate, read_buf_size;
17 Bool allow_broken_certificate;
20 GF_List *skip_proxy_servers;
22 GF_List *cache_entries;
23 @@ -392,10 +392,18 @@ static Bool init_ssl_lib() {
24 GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[HTTPS] Error while initializing Random Number generator, failed to init SSL !\n"));
28 + /* per https://www.openssl.org/docs/man1.1.0/ssl/OPENSSL_init_ssl.html
29 + ** As of version 1.1.0 OpenSSL will automatically allocate all resources that it needs so no explicit initialisation is required.
30 + ** Similarly it will also automatically deinitialise as required.
32 +#if OPENSSL_VERSION_NUMBER < 0x10100000L
34 SSL_load_error_strings();
35 SSLeay_add_all_algorithms();
36 SSLeay_add_ssl_algorithms();
39 _ssl_is_initialized = GF_TRUE;
40 GF_LOG(GF_LOG_DEBUG, GF_LOG_NETWORK, ("[HTTPS] Initalization of SSL library complete.\n"));
42 @@ -422,6 +430,7 @@ static int ssl_init(GF_DownloadManager *dm, u32 mode)
46 +#if OPENSSL_VERSION_NUMBER < 0x10100000L
48 meth = SSLv23_client_method();
50 @@ -436,6 +445,11 @@ static int ssl_init(GF_DownloadManager *dm, u32 mode)
52 meth = TLSv1_client_method();
54 +#else /* for openssl 1.1+ this is the prefered method */
56 + meth = TLS_client_method();
62 @@ -1225,7 +1239,7 @@ static GF_Err gf_dm_read_data(GF_DownloadSession *sess, char *data, u32 data_siz
64 return GF_IP_CONNECTION_CLOSED;
71 @@ -1451,7 +1465,11 @@ static void gf_dm_connect(GF_DownloadSession *sess)
72 const GENERAL_NAME *altname = sk_GENERAL_NAME_value(altnames, i);
73 if (altname->type == GEN_DNS)
75 - unsigned char *altname_str = ASN1_STRING_data(altname->d.ia5);
76 + #if OPENSSL_VERSION_NUMBER < 0x10100000L
77 + unsigned char *altname_str = ASN1_STRING_data(altname->d.ia5);
79 + unsigned char *altname_str = (unsigned char *)ASN1_STRING_get0_data(altname->d.ia5);
81 gf_list_add(valid_names, altname_str);