From 4f68ea16a3619d2206c652ba8c7c76c4158dcdca Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 13 Feb 2020 17:10:35 +0000 Subject: [Minor] Fix some of the moved functions --- src/libserver/ssl_util.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/libserver/ssl_util.c') diff --git a/src/libserver/ssl_util.c b/src/libserver/ssl_util.c index f4e55fbea..a094eaf45 100644 --- a/src/libserver/ssl_util.c +++ b/src/libserver/ssl_util.c @@ -19,11 +19,15 @@ #include "libserver/logger.h" #include "ssl_util.h" #include "unix-std.h" +#include "cryptobox.h" +#include "contrib/libottery/ottery.h" #include #include #include #include +#include +#include #include enum rspamd_ssl_state { @@ -970,4 +974,42 @@ gpointer rspamd_init_ssl_ctx_noverify (void) #endif return ssl_ctx_noverify; +} + +void +rspamd_openssl_maybe_init (void) +{ + static gboolean openssl_initialized = FALSE; + + if (!openssl_initialized) { + ERR_load_crypto_strings (); + SSL_load_error_strings (); + + OpenSSL_add_all_algorithms (); + OpenSSL_add_all_digests (); + OpenSSL_add_all_ciphers (); + +#if OPENSSL_VERSION_NUMBER >= 0x1000104fL && !defined(LIBRESSL_VERSION_NUMBER) + ENGINE_load_builtin_engines (); +#endif +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) + SSL_library_init (); +#else + OPENSSL_init_ssl (0, NULL); +#endif + +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) + OPENSSL_config (NULL); +#endif + if (RAND_status () == 0) { + guchar seed[128]; + + /* Try to use ottery to seed rand */ + ottery_rand_bytes (seed, sizeof (seed)); + RAND_seed (seed, sizeof (seed)); + rspamd_explicit_memzero (seed, sizeof (seed)); + } + + openssl_initialized = TRUE; + } } \ No newline at end of file -- cgit v1.2.3