Removed the last bits of OpenSSL code called directly

This commit is contained in:
Jan Vidar Krey 2012-10-17 20:53:05 +02:00
parent 1e0927f510
commit c50eb90bee
3 changed files with 41 additions and 21 deletions

View File

@ -49,7 +49,11 @@ int net_initialize()
} }
#endif /* WINSOCK */ #endif /* WINSOCK */
if (!net_backend_init()) if (!net_backend_init()
#ifdef SSL_SUPPORT
|| !net_ssl_library_init()
#endif
)
{ {
#ifdef WINSOCK #ifdef WINSOCK
WSACleanup(); WSACleanup();
@ -57,15 +61,6 @@ int net_initialize()
return -1; return -1;
} }
net_stats_initialize(); net_stats_initialize();
#ifdef SSL_SUPPORT
#ifdef SSL_USE_OPENSSL
LOG_TRACE("Initializing OpenSSL...");
SSL_library_init();
SSL_load_error_strings();
#endif /* SSL_USE_OPENSSL */
#endif /* SSL_SUPPORT */
net_initialized = 1; net_initialized = 1;
return 0; return 0;
} }
@ -102,11 +97,7 @@ int net_destroy()
net_backend_shutdown(); net_backend_shutdown();
#ifdef SSL_SUPPORT #ifdef SSL_SUPPORT
#ifdef SSL_USE_OPENSSL net_ssl_library_shutdown();
ERR_free_strings();
EVP_cleanup();
CRYPTO_cleanup_all_ex_data();
#endif /* SSL_USE_OPENSSL */
#endif /* SSL_SUPPORT */ #endif /* SSL_SUPPORT */
#ifdef WINSOCK #ifdef WINSOCK

View File

@ -52,6 +52,31 @@ const char* net_ssl_get_provider()
return OPENSSL_VERSION_TEXT; return OPENSSL_VERSION_TEXT;
} }
int net_ssl_library_init()
{
LOG_TRACE("Initializing OpenSSL...");
SSL_library_init();
SSL_load_error_strings();
return 1;
}
int net_ssl_library_shutdown()
{
ERR_clear_error();
ERR_remove_state(0);
ENGINE_cleanup();
CONF_modules_unload(1);
ERR_free_strings();
EVP_cleanup();
CRYPTO_cleanup_all_ex_data();
// sk_SSL_COMP_free(SSL_COMP_get_compression_methods());
return 1;
}
/** /**
* Create a new SSL context. * Create a new SSL context.
@ -303,3 +328,4 @@ void net_ssl_callback(struct net_connection* con, int events)
#endif /* SSL_USE_OPENSSL */ #endif /* SSL_USE_OPENSSL */
#endif /* SSL_SUPPORT */ #endif /* SSL_SUPPORT */

View File

@ -50,6 +50,12 @@ struct ssl_context_handle;
*/ */
extern const char* net_ssl_get_provider(); extern const char* net_ssl_get_provider();
/**
* return 0 if error, 1 on success.
*/
extern int net_ssl_library_init();
extern int net_ssl_library_shutdown();
/** /**
* Create a new SSL context. * Create a new SSL context.
*/ */
@ -91,11 +97,8 @@ extern void net_ssl_callback(struct net_connection* con, int events);
extern ssize_t net_con_ssl_handshake(struct net_connection* con, enum net_con_ssl_mode, struct ssl_context_handle* ssl_ctx); extern ssize_t net_con_ssl_handshake(struct net_connection* con, enum net_con_ssl_mode, struct ssl_context_handle* ssl_ctx);
extern SSL* net_con_get_ssl(struct net_connection* con);
#ifdef SSL_USE_OPENSSL
extern void net_con_set_ssl(struct net_connection* con, SSL*);
#endif // SSL_USE_OPENSSL
extern int net_con_is_ssl(struct net_connection* con); extern int net_con_is_ssl(struct net_connection* con);
#endif /* SSL_SUPPORT */ #endif /* SSL_SUPPORT */
#endif /* HAVE_UHUB_NETWORK_TLS_H */ #endif /* HAVE_UHUB_NETWORK_TLS_H */