Mercurial > hg > orthanc
comparison Core/Toolbox.cpp @ 3802:6462ecaa045b
fix unit test, reorganization of OpenSSL initialization
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 02 Apr 2020 12:54:45 +0200 |
parents | e7ff4f9b34bd |
children | d86bddb50972 |
comparison
equal
deleted
inserted
replaced
3801:9fe1d64a748c | 3802:6462ecaa045b |
---|---|
1678 return boost::locale::conv::utf_to_utf<char>(w, boost::locale::conv::skip); | 1678 return boost::locale::conv::utf_to_utf<char>(w, boost::locale::conv::skip); |
1679 } | 1679 } |
1680 #endif | 1680 #endif |
1681 | 1681 |
1682 | 1682 |
1683 | |
1684 #if ORTHANC_ENABLE_SSL == 0 | |
1685 /** | |
1686 * OpenSSL is disabled | |
1687 **/ | |
1683 void Toolbox::InitializeOpenSsl() | 1688 void Toolbox::InitializeOpenSsl() |
1684 { | 1689 { |
1685 #if ORTHANC_ENABLE_SSL == 1 | 1690 } |
1691 | |
1692 void Toolbox::FinalizeOpenSsl() | |
1693 { | |
1694 } | |
1695 | |
1696 | |
1697 #elif (ORTHANC_ENABLE_SSL == 1 && \ | |
1698 OPENSSL_VERSION_NUMBER < 0x10100000L) | |
1699 /** | |
1700 * OpenSSL < 1.1.0 | |
1701 **/ | |
1702 void Toolbox::InitializeOpenSsl() | |
1703 { | |
1686 // https://wiki.openssl.org/index.php/Library_Initialization | 1704 // https://wiki.openssl.org/index.php/Library_Initialization |
1687 SSL_library_init(); | 1705 SSL_library_init(); |
1688 SSL_load_error_strings(); | 1706 SSL_load_error_strings(); |
1689 OpenSSL_add_all_algorithms(); | 1707 OpenSSL_add_all_algorithms(); |
1690 ERR_load_crypto_strings(); | 1708 ERR_load_crypto_strings(); |
1691 #endif | 1709 } |
1692 } | |
1693 | |
1694 | 1710 |
1695 void Toolbox::FinalizeOpenSsl() | 1711 void Toolbox::FinalizeOpenSsl() |
1696 { | 1712 { |
1697 #if ORTHANC_ENABLE_SSL == 1 | |
1698 // Finalize OpenSSL | 1713 // Finalize OpenSSL |
1699 // https://wiki.openssl.org/index.php/Library_Initialization#Cleanup | 1714 // https://wiki.openssl.org/index.php/Library_Initialization#Cleanup |
1700 #ifdef FIPS_mode_set | 1715 #ifdef FIPS_mode_set |
1701 FIPS_mode_set(0); | 1716 FIPS_mode_set(0); |
1702 #endif | 1717 #endif |
1708 CONF_modules_unload(1); | 1723 CONF_modules_unload(1); |
1709 EVP_cleanup(); | 1724 EVP_cleanup(); |
1710 CRYPTO_cleanup_all_ex_data(); | 1725 CRYPTO_cleanup_all_ex_data(); |
1711 ERR_remove_state(0); | 1726 ERR_remove_state(0); |
1712 ERR_free_strings(); | 1727 ERR_free_strings(); |
1713 #endif | 1728 } |
1714 } | 1729 |
1730 | |
1731 #elif (ORTHANC_ENABLE_SSL == 1 && \ | |
1732 OPENSSL_VERSION_NUMBER >= 0x10100000L) | |
1733 /** | |
1734 * OpenSSL >= 1.1.0. In this case, the initialization is | |
1735 * automatically done by the functions of OpenSSL. | |
1736 * https://wiki.openssl.org/index.php/Library_Initialization | |
1737 **/ | |
1738 void Toolbox::InitializeOpenSsl() | |
1739 { | |
1740 } | |
1741 | |
1742 void Toolbox::FinalizeOpenSsl() | |
1743 { | |
1744 } | |
1745 | |
1746 #else | |
1747 # error "Support your platform here" | |
1748 #endif | |
1749 | |
1715 | 1750 |
1716 | 1751 |
1717 std::string Toolbox::GenerateUuid() | 1752 std::string Toolbox::GenerateUuid() |
1718 { | 1753 { |
1719 #ifdef WIN32 | 1754 #ifdef WIN32 |