diff --git a/src/sbbs3/ssl.c b/src/sbbs3/ssl.c index 7fe10af0ffb0e72e262a2be723468c6e25632748..09177e6ffbbda89f0028124088e97afa5720f9ec 100644 --- a/src/sbbs3/ssl.c +++ b/src/sbbs3/ssl.c @@ -53,6 +53,7 @@ static bool get_error_string(int status, CRYPT_SESSION sess, char estr[SSL_ESTR_ static pthread_once_t crypt_init_once = PTHREAD_ONCE_INIT; static pthread_mutex_t ssl_cert_mutex; +static bool cryptlib_initialized; static void do_cryptEnd(void) { @@ -66,6 +67,7 @@ static void internal_do_cryptInit(void) if((ret=cryptInit())==CRYPT_OK) { cryptAddRandom(NULL,CRYPT_RANDOM_SLOWPOLL); atexit(do_cryptEnd); + cryptlib_initialized = true; } else { lprintf(LOG_ERR,"cryptInit() returned %d", ret); @@ -81,6 +83,11 @@ int DLLCALL do_cryptInit(void) return 0; } +bool DLLCALL is_crypt_initialized(void) +{ + return cryptlib_initialized; +} + #define DO(x) get_error_string(x, ssl_context, estr, __FILE__, __LINE__) CRYPT_CONTEXT DLLCALL get_ssl_cert(scfg_t *cfg, char estr[SSL_ESTR_LEN]) diff --git a/src/sbbs3/ssl.h b/src/sbbs3/ssl.h index 439c07c066b47985186a3a5888f5b74457ce3533..e1df40807e00839793e4467ff8aa8434525364ff 100644 --- a/src/sbbs3/ssl.h +++ b/src/sbbs3/ssl.h @@ -4,6 +4,7 @@ #include "sbbs.h" // For DLLEXPORT #include <cryptlib.h> #include "scfgdefs.h" +#include <stdbool.h> #ifdef DLLEXPORT #undef DLLEXPORT @@ -38,6 +39,7 @@ DLLEXPORT char* DLLCALL get_crypt_attribute(CRYPT_SESSION sess, C_IN CRYPT_ATTRI DLLEXPORT char* DLLCALL get_crypt_error(CRYPT_SESSION sess); DLLEXPORT CRYPT_CONTEXT DLLCALL get_ssl_cert(scfg_t *cfg, char estr[SSL_ESTR_LEN]); DLLEXPORT int DLLCALL do_cryptInit(void); +DLLEXPORT bool DLLCALL is_crypt_initialized(void); #if defined(__cplusplus) } diff --git a/src/sbbs3/ver.cpp b/src/sbbs3/ver.cpp index 2198b42743c2d38828c941baa1658079ad013824..3440e92376848204d907d4d5ac3f528092c3b8e7 100644 --- a/src/sbbs3/ver.cpp +++ b/src/sbbs3/ver.cpp @@ -37,6 +37,7 @@ ****************************************************************************/ #include "sbbs.h" +#include "ssl.h" const char* beta_version = " "; /* Space if non-beta, " beta" otherwise */ @@ -109,7 +110,7 @@ void sbbs_t::ver() socklib_version(str,SOCKLIB_DESC); #ifdef USE_CRYPTLIB - { + if(is_crypt_initialized()) { int cl_major=0, cl_minor=0, cl_step=0; int result; result = cryptGetAttribute(CRYPT_UNUSED, CRYPT_OPTION_INFO_MAJORVERSION, &cl_major);