summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@samsung.com>2015-03-17 08:49:59 +0100
committerCedric BAIL <cedric@osg.samsung.com>2015-03-17 09:58:17 +0100
commitcc88832353f01b754fcb199c28f7baa20679bdb9 (patch)
treeb705bdd747d4d845b9ba6d0f39a87e12b20b4130
parent2d342c281473cc9f03b76dfe234f60fc60377c4a (diff)
ecore_con: depend on emile for initializing crypto library.
-rw-r--r--configure.ac1
-rw-r--r--src/lib/ecore_con/ecore_con_ssl.c80
-rw-r--r--src/lib/emile/emile_main.c2
3 files changed, 18 insertions, 65 deletions
diff --git a/configure.ac b/configure.ac
index e4e2ab33ed..de5fa7d765 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2475,6 +2475,7 @@ EFL_INTERNAL_DEPEND_PKG([ECORE_CON], [eo])
2475EFL_INTERNAL_DEPEND_PKG([ECORE_CON], [eet]) 2475EFL_INTERNAL_DEPEND_PKG([ECORE_CON], [eet])
2476EFL_INTERNAL_DEPEND_PKG([ECORE_CON], [eina]) 2476EFL_INTERNAL_DEPEND_PKG([ECORE_CON], [eina])
2477EFL_INTERNAL_DEPEND_PKG([ECORE_CON], [ecore]) 2477EFL_INTERNAL_DEPEND_PKG([ECORE_CON], [ecore])
2478EFL_INTERNAL_DEPEND_PKG([ECORE_CON], [emile])
2478 2479
2479EFL_ADD_LIBS([ECORE_CON], [-lm]) 2480EFL_ADD_LIBS([ECORE_CON], [-lm])
2480 2481
diff --git a/src/lib/ecore_con/ecore_con_ssl.c b/src/lib/ecore_con/ecore_con_ssl.c
index c2b3d5794f..33fb0ad315 100644
--- a/src/lib/ecore_con/ecore_con_ssl.c
+++ b/src/lib/ecore_con/ecore_con_ssl.c
@@ -26,6 +26,9 @@
26#endif 26#endif
27 27
28#include <sys/stat.h> 28#include <sys/stat.h>
29
30#include <Emile.h>
31
29#include "Ecore.h" 32#include "Ecore.h"
30#include "ecore_con_private.h" 33#include "ecore_con_private.h"
31 34
@@ -35,8 +38,6 @@ EAPI int ECORE_CON_EVENT_SERVER_UPGRADE = 0;
35static int _init_con_ssl_init_count = 0; 38static int _init_con_ssl_init_count = 0;
36 39
37#ifdef HAVE_GNUTLS 40#ifdef HAVE_GNUTLS
38GCRY_THREAD_OPTION_PTHREAD_IMPL;
39
40static int _client_connected = 0; 41static int _client_connected = 0;
41 42
42# define SSL_SUFFIX(ssl_func) ssl_func ## _gnutls 43# define SSL_SUFFIX(ssl_func) ssl_func ## _gnutls
@@ -425,11 +426,6 @@ _openssl_print_session(SSL *ssl)
425 } \ 426 } \
426 while (0) 427 while (0)
427 428
428static Ecore_Con_Ssl_Error
429 SSL_SUFFIX(_ecore_con_ssl_init) (void);
430static Ecore_Con_Ssl_Error
431 SSL_SUFFIX(_ecore_con_ssl_shutdown) (void);
432
433static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_cafile_add) (Ecore_Con_Server *svr, const char *ca_file); 429static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_cafile_add) (Ecore_Con_Server *svr, const char *ca_file);
434static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_crl_add) (Ecore_Con_Server *svr, const char *crl_file); 430static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_crl_add) (Ecore_Con_Server *svr, const char *crl_file);
435static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_cert_add) (Ecore_Con_Server *svr, const char *cert); 431static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_cert_add) (Ecore_Con_Server *svr, const char *cert);
@@ -457,7 +453,16 @@ ecore_con_ssl_init(void)
457{ 453{
458 if (!_init_con_ssl_init_count++) 454 if (!_init_con_ssl_init_count++)
459 { 455 {
460 SSL_SUFFIX(_ecore_con_ssl_init) (); 456#ifdef ISCOMFITOR
457 if (eina_log_domain_level_check(_ecore_con_log_dom,
458 EINA_LOG_LEVEL_DBG))
459 {
460 gnutls_global_set_log_level(9);
461 gnutls_global_set_log_function(_gnutls_log_func);
462 }
463#endif
464 emile_init();
465
461#if _ECORE_CON_SSL_AVAILABLE != 0 466#if _ECORE_CON_SSL_AVAILABLE != 0
462 ECORE_CON_EVENT_CLIENT_UPGRADE = ecore_event_type_new(); 467 ECORE_CON_EVENT_CLIENT_UPGRADE = ecore_event_type_new();
463 ECORE_CON_EVENT_SERVER_UPGRADE = ecore_event_type_new(); 468 ECORE_CON_EVENT_SERVER_UPGRADE = ecore_event_type_new();
@@ -478,7 +483,7 @@ ecore_con_ssl_shutdown(void)
478 } 483 }
479 484
480 if (!--_init_con_ssl_init_count) 485 if (!--_init_con_ssl_init_count)
481 SSL_SUFFIX(_ecore_con_ssl_shutdown) (); 486 emile_shutdown();
482 487
483 return _init_con_ssl_init_count; 488 return _init_con_ssl_init_count;
484} 489}
@@ -740,33 +745,7 @@ ecore_con_ssl_client_upgrade(Ecore_Con_Client *obj, Ecore_Con_Type ssl_type)
740 */ 745 */
741 746
742static Ecore_Con_Ssl_Error 747static Ecore_Con_Ssl_Error
743_ecore_con_ssl_init_gnutls(void) 748_ecore_con_ssl_server_prepare_gnutls(Ecore_Con_Server *svr,
744{
745 if (gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread))
746 WRN("YOU ARE USING PTHREADS, BUT I CANNOT INITIALIZE THREADSAFE GCRYPT OPERATIONS!");
747 if (gnutls_global_init())
748 return ECORE_CON_SSL_ERROR_INIT_FAILED;
749
750#ifdef ISCOMFITOR
751 if (eina_log_domain_level_check(_ecore_con_log_dom, EINA_LOG_LEVEL_DBG))
752 {
753 gnutls_global_set_log_level(9);
754 gnutls_global_set_log_function(_gnutls_log_func);
755 }
756#endif
757 return ECORE_CON_SSL_ERROR_NONE;
758}
759
760static Ecore_Con_Ssl_Error
761_ecore_con_ssl_shutdown_gnutls(void)
762{
763 gnutls_global_deinit();
764
765 return ECORE_CON_SSL_ERROR_NONE;
766}
767
768static Ecore_Con_Ssl_Error
769_ecore_con_ssl_server_prepare_gnutls(Ecore_Con_Server *obj,
770 int ssl_type) 749 int ssl_type)
771{ 750{
772 Ecore_Con_Server_Data *svr = eo_data_scope_get(obj, ECORE_CON_SERVER_CLASS); 751 Ecore_Con_Server_Data *svr = eo_data_scope_get(obj, ECORE_CON_SERVER_CLASS);
@@ -1390,22 +1369,6 @@ _ecore_con_ssl_client_write_gnutls(Ecore_Con_Client *obj,
1390 */ 1369 */
1391 1370
1392static Ecore_Con_Ssl_Error 1371static Ecore_Con_Ssl_Error
1393_ecore_con_ssl_init_openssl(void)
1394{
1395 SSL_library_init();
1396 SSL_load_error_strings();
1397 OpenSSL_add_all_algorithms();
1398
1399 return ECORE_CON_SSL_ERROR_NONE;
1400}
1401
1402static Ecore_Con_Ssl_Error
1403_ecore_con_ssl_shutdown_openssl(void)
1404{
1405 ERR_free_strings();
1406 EVP_cleanup();
1407 return ECORE_CON_SSL_ERROR_NONE;
1408}
1409 1372
1410static Ecore_Con_Ssl_Error 1373static Ecore_Con_Ssl_Error
1411_ecore_con_ssl_server_prepare_openssl(Ecore_Con_Server *obj, 1374_ecore_con_ssl_server_prepare_openssl(Ecore_Con_Server *obj,
@@ -1911,19 +1874,6 @@ _ecore_con_ssl_client_write_openssl(Ecore_Con_Client *obj,
1911/* 1874/*
1912 * No Ssl 1875 * No Ssl
1913 */ 1876 */
1914
1915static Ecore_Con_Ssl_Error
1916_ecore_con_ssl_init_none(void)
1917{
1918 return ECORE_CON_SSL_ERROR_NONE;
1919}
1920
1921static Ecore_Con_Ssl_Error
1922_ecore_con_ssl_shutdown_none(void)
1923{
1924 return ECORE_CON_SSL_ERROR_NONE;
1925}
1926
1927static Ecore_Con_Ssl_Error 1877static Ecore_Con_Ssl_Error
1928_ecore_con_ssl_server_prepare_none(Ecore_Con_Server *svr EINA_UNUSED, 1878_ecore_con_ssl_server_prepare_none(Ecore_Con_Server *svr EINA_UNUSED,
1929 int ssl_type EINA_UNUSED) 1879 int ssl_type EINA_UNUSED)
diff --git a/src/lib/emile/emile_main.c b/src/lib/emile/emile_main.c
index 5aa80acd66..9171b565a6 100644
--- a/src/lib/emile/emile_main.c
+++ b/src/lib/emile/emile_main.c
@@ -72,6 +72,8 @@ emile_init(void)
72#endif /* ifdef HAVE_GNUTLS */ 72#endif /* ifdef HAVE_GNUTLS */
73#ifdef HAVE_OPENSSL 73#ifdef HAVE_OPENSSL
74 ERR_load_crypto_strings(); 74 ERR_load_crypto_strings();
75 SSL_library_init();
76 SSL_load_error_strings();
75 OpenSSL_add_all_algorithms(); 77 OpenSSL_add_all_algorithms();
76#endif /* ifdef HAVE_OPENSSL */ 78#endif /* ifdef HAVE_OPENSSL */
77 79