diff --git a/src/ripple/basics/impl/CheckLibraryVersions.cpp b/src/ripple/basics/impl/CheckLibraryVersions.cpp index b4268ba785..af15a63485 100644 --- a/src/ripple/basics/impl/CheckLibraryVersions.cpp +++ b/src/ripple/basics/impl/CheckLibraryVersions.cpp @@ -29,12 +29,8 @@ namespace ripple { namespace version { -using VersionNumber = unsigned long long; - -const char boostMinimal[] = "1.57.0"; -const char openSSLMinimal[] = "1.0.1-g"; - -std::string boostVersion(VersionNumber boostVersion) +std::string +boostVersion(VersionNumber boostVersion) { std::stringstream ss; ss << (boostVersion / 100000) << "." @@ -43,7 +39,8 @@ std::string boostVersion(VersionNumber boostVersion) return ss.str(); } -std::string openSSLVersion(VersionNumber openSSLVersion) +std::string +openSSLVersion(VersionNumber openSSLVersion) { std::stringstream ss; ss << (openSSLVersion / 0x10000000L) << "." @@ -80,18 +77,45 @@ void checkVersion(std::string name, std::string required, std::string actual) void checkBoost(std::string version) { + const char* boostMinimal = "1.57.0"; checkVersion("Boost", boostMinimal, version); } void checkOpenSSL(std::string version) { - checkVersion("OpenSSL", openSSLMinimal, version); + // The minimal version depends on whether we're linking + // against 1.0.1 or later versions: + beast::SemanticVersion v; + + char const* openSSLMinimal101 = "1.0.1-g"; + char const* openSSLMinimal102 = "1.0.2-j"; + + if (v.parse (version) && + v.majorVersion == 1 && + v.minorVersion == 0 && + v.patchVersion == 1) + { + // Use of the 1.0.1 series should be dropped as soon + // as possible since as of January 2, 2017 it is no + // longer supported. Unfortunately, a number of + // platforms officially supported by Ripple still + // use the 1.0.1 branch. + // + // Additionally, requiring 1.0.1u (the latest) is + // similarly not possible, since those officially + // supported platforms use older releases and + // backport important fixes. + checkVersion ("OpenSSL", openSSLMinimal101, version); + return; + } + + checkVersion ("OpenSSL", openSSLMinimal102, version); } void checkLibraryVersions() { - checkBoost(); - checkOpenSSL(); + checkBoost(boostVersion(BOOST_VERSION)); + checkOpenSSL(openSSLVersion(OPENSSL_VERSION_NUMBER)); } } // namespace version diff --git a/src/ripple/basics/impl/CheckLibraryVersionsImpl.h b/src/ripple/basics/impl/CheckLibraryVersionsImpl.h index f106ccf288..976f3ef8b0 100644 --- a/src/ripple/basics/impl/CheckLibraryVersionsImpl.h +++ b/src/ripple/basics/impl/CheckLibraryVersionsImpl.h @@ -21,8 +21,6 @@ #define RIPPLE_BASICS_CHECKLIBRARYVERSIONSIMPL_H_INCLUDED #include -#include -#include namespace ripple { namespace version { @@ -30,19 +28,19 @@ namespace version { /** Both Boost and OpenSSL have integral version numbers. */ using VersionNumber = unsigned long long; -/** Minimal required boost version. */ -extern const char boostMinimal[]; +std::string +boostVersion(VersionNumber boostVersion); -/** Minimal required OpenSSL version. */ -extern const char openSSLMinimal[]; +std::string +openSSLVersion(VersionNumber openSSLVersion); -std::string boostVersion(VersionNumber boostVersion = BOOST_VERSION); -std::string openSSLVersion( - VersionNumber openSSLVersion = OPENSSL_VERSION_NUMBER); +void checkVersion( + std::string name, + std::string required, + std::string actual); -void checkVersion(std::string name, std::string required, std::string actual); -void checkBoost(std::string version = boostVersion()); -void checkOpenSSL(std::string version = openSSLVersion()); +void checkBoost(std::string version); +void checkOpenSSL(std::string version); } // namespace version } // namespace ripple diff --git a/src/ripple/beast/core/SemanticVersion.cpp b/src/ripple/beast/core/SemanticVersion.cpp index 99515a7025..898f020106 100644 --- a/src/ripple/beast/core/SemanticVersion.cpp +++ b/src/ripple/beast/core/SemanticVersion.cpp @@ -157,7 +157,7 @@ SemanticVersion::SemanticVersion (std::string const& version) throw std::invalid_argument ("invalid version string"); } -bool SemanticVersion::parse (std::string const& input, bool debug) +bool SemanticVersion::parse (std::string const& input) { // May not have leading or trailing whitespace auto left_iter = std::find_if_not (input.begin (), input.end (), diff --git a/src/ripple/beast/core/SemanticVersion.h b/src/ripple/beast/core/SemanticVersion.h index 9fa8e57a19..83bdd7248d 100644 --- a/src/ripple/beast/core/SemanticVersion.h +++ b/src/ripple/beast/core/SemanticVersion.h @@ -52,7 +52,7 @@ public: The parsing is as strict as possible. @return `true` if the string was parsed. */ - bool parse (std::string const& input, bool debug = false); + bool parse (std::string const& input); /** Produce a string from semantic version components. */ std::string print () const; diff --git a/src/test/basics/CheckLibraryVersions_test.cpp b/src/test/basics/CheckLibraryVersions_test.cpp index 84fd4ecdcb..1d7e69f28d 100644 --- a/src/test/basics/CheckLibraryVersions_test.cpp +++ b/src/test/basics/CheckLibraryVersions_test.cpp @@ -27,51 +27,26 @@ namespace version { struct CheckLibraryVersions_test : beast::unit_test::suite { - void print_message() + void testBadOpenSSL() { - log << "ssl minimal: " << openSSLMinimal << "\n" - << "ssl actual: " << openSSLVersion() << "\n" - << "boost minimal: " << boostMinimal << "\n" - << "boost actual: " << boostVersion() << "\n" - << std::flush; + testcase ("Out-of-Date OpenSSL"); + except ([&]{ checkOpenSSL("0.9.8-o"); }); + except ([&]{ checkOpenSSL("1.0.1-d"); }); + except ([&]{ checkOpenSSL("1.0.2-c"); }); } - void test_bad_ssl() + void testBadBoost() { - std::string error; - try { - checkOpenSSL(openSSLVersion(0x0090819fL)); - } catch (std::runtime_error& e) { - error = e.what(); - } - auto expectedError = "Your OpenSSL library is out of date.\n" - "Your version: 0.9.8-o\n" - "Required version: "; - unexpected(error.find(expectedError) != 0, error); + testcase ("Out-of-Date Boost"); + except ([&]{ checkBoost ("1.54.0"); }); } - void test_bad_boost() - { - std::string error; - try { - checkBoost(boostVersion(105400)); - } catch (std::runtime_error& e) { - error = e.what(); - } - auto expectedError = "Your Boost library is out of date.\n" - "Your version: 1.54.0\n" - "Required version: "; - unexpected(error.find(expectedError) != 0, error); - } - - void run() { - print_message(); - checkLibraryVersions(); + unexcept ([&]{ checkLibraryVersions(); }); - test_bad_ssl(); - test_bad_boost(); + testBadOpenSSL(); + testBadBoost(); } };