Browse code

tls: reintroduced use of OPENSSL_cleanup() on mod destroy

- by that avoid executing it on atexit() callback, when shm is gone

Daniel-Constantin Mierla authored on 05/10/2020 13:28:23
Showing 1 changed files
... ...
@@ -627,13 +627,14 @@ int tls_h_mod_pre_init_f(void)
627 627
 		return 0;
628 628
 	}
629 629
 	LM_DBG("preparing tls env for modules initialization\n");
630
-#if OPENSSL_VERSION_NUMBER < 0x010100000L || defined(LIBRESSL_VERSION_NUMBER)
630
+#if OPENSSL_VERSION_NUMBER >= 0x010100000L && !defined(LIBRESSL_VERSION_NUMBER)
631
+	LM_DBG("preparing tls env for modules initialization (libssl >=1.1)\n");
632
+	OPENSSL_init_ssl(0, NULL);
633
+#else
631 634
 	LM_DBG("preparing tls env for modules initialization (libssl <=1.0)\n");
632 635
 	SSL_library_init();
633
-	SSL_load_error_strings();
634
-#else
635
-	LM_DBG("preparing tls env for modules initialization (libssl >=1.1)\n");
636 636
 #endif
637
+	SSL_load_error_strings();
637 638
 	tls_mod_preinitialized=1;
638 639
 	return 0;
639 640
 }
... ...
@@ -865,7 +866,6 @@ int tls_check_sockets(tls_domains_cfg_t* cfg)
865 866
 void tls_h_mod_destroy_f(void)
866 867
 {
867 868
 	LM_DBG("tls module final tls destroy\n");
868
-#if OPENSSL_VERSION_NUMBER < 0x010100000L || defined(LIBRESSL_VERSION_NUMBER)
869 869
 	if(tls_mod_preinitialized > 0)
870 870
 		ERR_free_strings();
871 871
 	/* TODO: free all the ctx'es */
... ...
@@ -878,5 +878,4 @@ void tls_h_mod_destroy_f(void)
878 878
 	LM_DBG("executing openssl v1.1+ cleanup\n");
879 879
 	OPENSSL_cleanup();
880 880
 #endif
881
-#endif
882 881
 }