openssl_exception.cpp 702 B

123456789101112131415161718192021
  1. #include "openssl_exception.hpp"
  2. #include <mutex>
  3. #pragma comment(lib, "libcrypto")
  4. #pragma comment(lib, "crypt32") // required by libcrypto.lib
  5. #pragma comment(lib, "ws2_32") // required by libcrypto.lib
  6. namespace nkg::exceptions {
  7. openssl_exception::openssl_exception(std::string_view file, int line, error_code_t openssl_error_code, std::string_view message) noexcept :
  8. ::nkg::exception(file, line, message)
  9. {
  10. static std::once_flag onceflag_load_crypto_strings;
  11. std::call_once(onceflag_load_crypto_strings, []() { ERR_load_crypto_strings(); });
  12. m_error_code = openssl_error_code;
  13. m_error_string = ERR_reason_error_string(m_error_code);
  14. }
  15. }