|
@@ -61,6 +61,7 @@
|
|
|
#include "tls_cfg.h"
|
|
|
|
|
|
/* will be set to 1 when the TLS env is initialized to make destroy safe */
|
|
|
+static int tls_mod_preinitialized = 0;
|
|
|
static int tls_mod_initialized = 0;
|
|
|
|
|
|
#if OPENSSL_VERSION_NUMBER < 0x00907000L
|
|
@@ -469,6 +470,7 @@ end:
|
|
|
|
|
|
/**
|
|
|
* tls pre-init function
|
|
|
+ * - executed when module is loaded
|
|
|
*/
|
|
|
int tls_pre_init(void)
|
|
|
{
|
|
@@ -493,6 +495,23 @@ int tls_pre_init(void)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * tls mod pre-init function
|
|
|
+ * - executed before any mod_init()
|
|
|
+ */
|
|
|
+int tls_mod_pre_init_h(void)
|
|
|
+{
|
|
|
+ if(tls_mod_preinitialized==1) {
|
|
|
+ LM_DBG("already mod pre-initialized\n");
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ DBG("============= :preparing tls env for modules initialization\n");
|
|
|
+ SSL_library_init();
|
|
|
+ SSL_load_error_strings();
|
|
|
+ tls_mod_preinitialized=1;
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
/*
|
|
|
* First step of TLS initialization
|
|
|
*/
|
|
@@ -511,6 +530,12 @@ int init_tls_h(void)
|
|
|
str s;
|
|
|
cfg_ctx_t* cfg_ctx;
|
|
|
|
|
|
+ if(tls_mod_initialized == 1) {
|
|
|
+ LM_DBG("already initialized\n");
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ DBG("initializing tls system\n");
|
|
|
+
|
|
|
#if OPENSSL_VERSION_NUMBER < 0x00907000L
|
|
|
WARN("You are using an old version of OpenSSL (< 0.9.7). Upgrade!\n");
|
|
|
#endif
|
|
@@ -657,8 +682,6 @@ int init_tls_h(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- SSL_library_init();
|
|
|
- SSL_load_error_strings();
|
|
|
init_ssl_methods();
|
|
|
tls_mod_initialized = 1;
|
|
|
return 0;
|
|
@@ -693,7 +716,7 @@ int tls_check_sockets(tls_domains_cfg_t* cfg)
|
|
|
void destroy_tls_h(void)
|
|
|
{
|
|
|
DBG("tls module final tls destroy\n");
|
|
|
- if(tls_mod_initialized > 0)
|
|
|
+ if(tls_mod_preinitialized > 0)
|
|
|
ERR_free_strings();
|
|
|
/* TODO: free all the ctx'es */
|
|
|
tls_destroy_cfg();
|