#include #include #include #include #include #include namespace fc { struct openssl_scope { static path _configurationFilePath; openssl_scope() { ERR_load_crypto_strings(); OpenSSL_add_all_algorithms(); const boost::filesystem::path& boostPath = _configurationFilePath; if(boostPath.empty() == false) { std::string varSetting("OPENSSL_CONF="); varSetting += _configurationFilePath.to_native_ansi_path(); #if defined(WIN32) _putenv((char*)varSetting.c_str()); #else putenv((char*)varSetting.c_str()); #endif } #if OPENSSL_VERSION_NUMBER < 0x10100000L // no longer needed as of OpenSSL 1.1 // if special initialization is necessary in versions 1.1 and above, // use OPENSSL_init_crypto OPENSSL_config(nullptr); #endif } ~openssl_scope() { EVP_cleanup(); ERR_free_strings(); } }; path openssl_scope::_configurationFilePath; void store_configuration_path(const path& filePath) { openssl_scope::_configurationFilePath = filePath; } int init_openssl() { static openssl_scope ossl; return 0; } }