peerplays-fc/src/crypto/openssl.cpp
2022-02-10 19:16:44 +00:00

57 lines
1.2 KiB
C++
Executable file

#include <fc/crypto/openssl.hpp>
#include <fc/filesystem.hpp>
#include <boost/filesystem/path.hpp>
#include <cstdlib>
#include <string>
#include <stdlib.h>
#include <fc/log/logger.hpp>
namespace fc
{
struct openssl_scope
{
static path _configurationFilePath;
openssl_scope()
{
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 (CONF_modules_load_file(_configurationFilePath.string().c_str(), "fc", CONF_MFLAGS_IGNORE_MISSING_FILE) <= 0) {
elog("FATAL: error loading configuration file\n");
ERR_print_errors_fp(stderr);
exit(1);
}
}
~openssl_scope()
{
}
};
path openssl_scope::_configurationFilePath;
void store_configuration_path(const path& filePath)
{
openssl_scope::_configurationFilePath = filePath;
}
int init_openssl()
{
static openssl_scope ossl;
return 0;
}
}