summaryrefslogtreecommitdiff
path: root/src/lib/ecore_con
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-01-04 17:44:13 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-01-04 17:47:38 +0900
commit2842165415a637939d24aa3e4a40fec0bba84f42 (patch)
treea86fa7f744ca914f7df35e565a28fffb4caa5b95 /src/lib/ecore_con
parent0ac95c40bcac812d1249b53814b94ccda3603cf9 (diff)
openssl 1.1 build break fixes
this fixes building against openssl 1.1 since it broke api in various ways by hiding structs and deprecating api's (this causes warnings not breaks unlike the struct hiding). this adapts to these changes and makes efl build again. @fix
Diffstat (limited to 'src/lib/ecore_con')
-rw-r--r--src/lib/ecore_con/efl_net_ssl_conn-openssl.c70
-rw-r--r--src/lib/ecore_con/efl_net_ssl_ctx-openssl.c4
2 files changed, 62 insertions, 12 deletions
diff --git a/src/lib/ecore_con/efl_net_ssl_conn-openssl.c b/src/lib/ecore_con/efl_net_ssl_conn-openssl.c
index 3ecabea3e7..88bb3bc204 100644
--- a/src/lib/ecore_con/efl_net_ssl_conn-openssl.c
+++ b/src/lib/ecore_con/efl_net_ssl_conn-openssl.c
@@ -33,10 +33,16 @@
33static int 33static int
34efl_net_socket_bio_create(BIO *b) 34efl_net_socket_bio_create(BIO *b)
35{ 35{
36#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
37 BIO_set_init(b, 1);
38 BIO_set_data(b, NULL);
39 BIO_set_flags(b, 0);
40#else
36 b->init = 1; 41 b->init = 1;
37 b->num = 0; 42 b->num = 0;
38 b->ptr = NULL; 43 b->ptr = NULL;
39 b->flags = 0; 44 b->flags = 0;
45#endif
40 return 1; 46 return 1;
41} 47}
42 48
@@ -44,9 +50,15 @@ static int
44efl_net_socket_bio_destroy(BIO *b) 50efl_net_socket_bio_destroy(BIO *b)
45{ 51{
46 if (!b) return 0; 52 if (!b) return 0;
53#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
54 BIO_set_init(b, 0);
55 BIO_set_data(b, NULL);
56 BIO_set_flags(b, 0);
57#else
47 b->init = 0; 58 b->init = 0;
48 b->ptr = NULL; 59 b->ptr = NULL;
49 b->flags = 0; 60 b->flags = 0;
61#endif
50 return 1; 62 return 1;
51} 63}
52 64
@@ -57,7 +69,11 @@ efl_net_socket_bio_read(BIO *b, char *buf, int len)
57 .mem = buf, 69 .mem = buf,
58 .len = len 70 .len = len
59 }; 71 };
72#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
73 Eo *sock = BIO_get_data(b);
74#else
60 Eo *sock = b->ptr; 75 Eo *sock = b->ptr;
76#endif
61 Eina_Error err; 77 Eina_Error err;
62 78
63 if ((!buf) || (len <= 0)) return 0; 79 if ((!buf) || (len <= 0)) return 0;
@@ -89,7 +105,11 @@ efl_net_socket_bio_write(BIO *b, const char *buf, int len)
89 .mem = buf, 105 .mem = buf,
90 .len = len 106 .len = len
91 }; 107 };
108#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
109 Eo *sock = BIO_get_data(b);
110#else
92 Eo *sock = b->ptr; 111 Eo *sock = b->ptr;
112#endif
93 Eina_Error err; 113 Eina_Error err;
94 114
95 if ((!buf) || (len <= 0)) return 0; 115 if ((!buf) || (len <= 0)) return 0;
@@ -129,17 +149,39 @@ efl_net_socket_bio_puts(BIO *b, const char *str)
129 return efl_net_socket_bio_write(b, str, strlen(str)); 149 return efl_net_socket_bio_write(b, str, strlen(str));
130} 150}
131 151
132static BIO_METHOD efl_net_socket_bio = { 152static BIO_METHOD *
133 0x400, /* 0x400 means source & sink */ 153__efl_net_socket_bio_get(void)
134 "efl_net_socket wrapper", 154{
135 efl_net_socket_bio_write, 155#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
136 efl_net_socket_bio_read, 156 static BIO_METHOD *efl_net_socket_bio = NULL;
137 efl_net_socket_bio_puts, 157
138 NULL, /* no gets */ 158 if (efl_net_socket_bio) return efl_net_socket_bio;
139 efl_net_socket_bio_ctrl, 159 efl_net_socket_bio = BIO_meth_new(0x400 /* 0x400 means source & sink */,
140 efl_net_socket_bio_create, 160 "efl_net_socket wrapper");
141 efl_net_socket_bio_destroy 161 BIO_meth_set_write(efl_net_socket_bio, efl_net_socket_bio_write);
142}; 162 BIO_meth_set_read(efl_net_socket_bio, efl_net_socket_bio_read);
163 BIO_meth_set_puts(efl_net_socket_bio, efl_net_socket_bio_puts);
164 BIO_meth_set_ctrl(efl_net_socket_bio, efl_net_socket_bio_ctrl);
165 BIO_meth_set_create(efl_net_socket_bio, efl_net_socket_bio_create);
166 BIO_meth_set_destroy(efl_net_socket_bio, efl_net_socket_bio_destroy);
167 // FIXME: some day we need to clean up, but for now a singleton alloc is ok
168 // BIO_meth_free(efl_net_socket_bio);
169 return efl_net_socket_bio;
170#else
171 static BIO_METHOD efl_net_socket_bio = {
172 0x400, /* 0x400 means source & sink */
173 "efl_net_socket wrapper",
174 efl_net_socket_bio_write,
175 efl_net_socket_bio_read,
176 efl_net_socket_bio_puts,
177 NULL, /* no gets */
178 efl_net_socket_bio_ctrl,
179 efl_net_socket_bio_create,
180 efl_net_socket_bio_destroy
181 };
182 return &efl_net_socket_bio;
183#endif
184}
143 185
144struct _Efl_Net_Ssl_Conn 186struct _Efl_Net_Ssl_Conn
145{ 187{
@@ -314,10 +356,14 @@ efl_net_ssl_conn_setup(Efl_Net_Ssl_Conn *conn, Eina_Bool is_dialer, Efl_Net_Sock
314 conn->ssl = efl_net_ssl_context_connection_new(context); 356 conn->ssl = efl_net_ssl_context_connection_new(context);
315 EINA_SAFETY_ON_NULL_RETURN_VAL(conn->ssl, ENOSYS); 357 EINA_SAFETY_ON_NULL_RETURN_VAL(conn->ssl, ENOSYS);
316 358
317 conn->bio = BIO_new(&efl_net_socket_bio); 359 conn->bio = BIO_new(__efl_net_socket_bio_get());
318 EINA_SAFETY_ON_NULL_GOTO(conn->bio, error_bio); 360 EINA_SAFETY_ON_NULL_GOTO(conn->bio, error_bio);
319 361
362#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
363 BIO_set_data(conn->bio, sock);
364#else
320 conn->bio->ptr = sock; 365 conn->bio->ptr = sock;
366#endif
321 367
322 SSL_set_bio(conn->ssl, conn->bio, conn->bio); 368 SSL_set_bio(conn->ssl, conn->bio, conn->bio);
323 if (is_dialer) 369 if (is_dialer)
diff --git a/src/lib/ecore_con/efl_net_ssl_ctx-openssl.c b/src/lib/ecore_con/efl_net_ssl_ctx-openssl.c
index 12614c728b..ce87b91bee 100644
--- a/src/lib/ecore_con/efl_net_ssl_ctx-openssl.c
+++ b/src/lib/ecore_con/efl_net_ssl_ctx-openssl.c
@@ -272,6 +272,7 @@ efl_net_ssl_ctx_setup(Efl_Net_Ssl_Ctx *ctx, Efl_Net_Ssl_Ctx_Config cfg)
272 ERR("ssl_ctx=%p SSLv3 is disabled in your OpenSSL build", ctx); 272 ERR("ssl_ctx=%p SSLv3 is disabled in your OpenSSL build", ctx);
273#endif 273#endif
274 break; 274 break;
275#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
275 case EFL_NET_SSL_CIPHER_TLSV1: 276 case EFL_NET_SSL_CIPHER_TLSV1:
276 ctx->ssl_ctx = SSL_CTX_new(TLSv1_client_method()); 277 ctx->ssl_ctx = SSL_CTX_new(TLSv1_client_method());
277 break; 278 break;
@@ -281,6 +282,7 @@ efl_net_ssl_ctx_setup(Efl_Net_Ssl_Ctx *ctx, Efl_Net_Ssl_Ctx_Config cfg)
281 case EFL_NET_SSL_CIPHER_TLSV1_2: 282 case EFL_NET_SSL_CIPHER_TLSV1_2:
282 ctx->ssl_ctx = SSL_CTX_new(TLSv1_2_client_method()); 283 ctx->ssl_ctx = SSL_CTX_new(TLSv1_2_client_method());
283 break; 284 break;
285#endif
284 default: 286 default:
285 ERR("ssl_ctx=%p unsupported cipher %d", ctx, cfg.cipher); 287 ERR("ssl_ctx=%p unsupported cipher %d", ctx, cfg.cipher);
286 return EINVAL; 288 return EINVAL;
@@ -302,6 +304,7 @@ efl_net_ssl_ctx_setup(Efl_Net_Ssl_Ctx *ctx, Efl_Net_Ssl_Ctx_Config cfg)
302 ERR("ssl_ctx=%p SSLv3 is disabled in your OpenSSL build", ctx); 304 ERR("ssl_ctx=%p SSLv3 is disabled in your OpenSSL build", ctx);
303#endif 305#endif
304 break; 306 break;
307#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
305 case EFL_NET_SSL_CIPHER_TLSV1: 308 case EFL_NET_SSL_CIPHER_TLSV1:
306 ctx->ssl_ctx = SSL_CTX_new(TLSv1_server_method()); 309 ctx->ssl_ctx = SSL_CTX_new(TLSv1_server_method());
307 break; 310 break;
@@ -311,6 +314,7 @@ efl_net_ssl_ctx_setup(Efl_Net_Ssl_Ctx *ctx, Efl_Net_Ssl_Ctx_Config cfg)
311 case EFL_NET_SSL_CIPHER_TLSV1_2: 314 case EFL_NET_SSL_CIPHER_TLSV1_2:
312 ctx->ssl_ctx = SSL_CTX_new(TLSv1_2_server_method()); 315 ctx->ssl_ctx = SSL_CTX_new(TLSv1_2_server_method());
313 break; 316 break;
317#endif
314 default: 318 default:
315 ERR("ssl_ctx=%p unsupported cipher %d", ctx, cfg.cipher); 319 ERR("ssl_ctx=%p unsupported cipher %d", ctx, cfg.cipher);
316 return EINVAL; 320 return EINVAL;