Require at least OpenSSL 1.0.1g or 1.0.2j and later (RIPD-1331)

This commit is contained in:
Nik Bougalis
2016-11-21 15:51:14 -08:00
parent a0a4eedc27
commit b00b81a861
5 changed files with 57 additions and 60 deletions

View File

@@ -29,12 +29,8 @@
namespace ripple { namespace ripple {
namespace version { namespace version {
using VersionNumber = unsigned long long; std::string
boostVersion(VersionNumber boostVersion)
const char boostMinimal[] = "1.57.0";
const char openSSLMinimal[] = "1.0.1-g";
std::string boostVersion(VersionNumber boostVersion)
{ {
std::stringstream ss; std::stringstream ss;
ss << (boostVersion / 100000) << "." ss << (boostVersion / 100000) << "."
@@ -43,7 +39,8 @@ std::string boostVersion(VersionNumber boostVersion)
return ss.str(); return ss.str();
} }
std::string openSSLVersion(VersionNumber openSSLVersion) std::string
openSSLVersion(VersionNumber openSSLVersion)
{ {
std::stringstream ss; std::stringstream ss;
ss << (openSSLVersion / 0x10000000L) << "." ss << (openSSLVersion / 0x10000000L) << "."
@@ -80,18 +77,45 @@ void checkVersion(std::string name, std::string required, std::string actual)
void checkBoost(std::string version) void checkBoost(std::string version)
{ {
const char* boostMinimal = "1.57.0";
checkVersion("Boost", boostMinimal, version); checkVersion("Boost", boostMinimal, version);
} }
void checkOpenSSL(std::string 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() void checkLibraryVersions()
{ {
checkBoost(); checkBoost(boostVersion(BOOST_VERSION));
checkOpenSSL(); checkOpenSSL(openSSLVersion(OPENSSL_VERSION_NUMBER));
} }
} // namespace version } // namespace version

View File

@@ -21,8 +21,6 @@
#define RIPPLE_BASICS_CHECKLIBRARYVERSIONSIMPL_H_INCLUDED #define RIPPLE_BASICS_CHECKLIBRARYVERSIONSIMPL_H_INCLUDED
#include <ripple/basics/CheckLibraryVersions.h> #include <ripple/basics/CheckLibraryVersions.h>
#include <boost/version.hpp>
#include <openssl/opensslv.h>
namespace ripple { namespace ripple {
namespace version { namespace version {
@@ -30,19 +28,19 @@ namespace version {
/** Both Boost and OpenSSL have integral version numbers. */ /** Both Boost and OpenSSL have integral version numbers. */
using VersionNumber = unsigned long long; using VersionNumber = unsigned long long;
/** Minimal required boost version. */ std::string
extern const char boostMinimal[]; boostVersion(VersionNumber boostVersion);
/** Minimal required OpenSSL version. */ std::string
extern const char openSSLMinimal[]; openSSLVersion(VersionNumber openSSLVersion);
std::string boostVersion(VersionNumber boostVersion = BOOST_VERSION); void checkVersion(
std::string openSSLVersion( std::string name,
VersionNumber openSSLVersion = OPENSSL_VERSION_NUMBER); std::string required,
std::string actual);
void checkVersion(std::string name, std::string required, std::string actual); void checkBoost(std::string version);
void checkBoost(std::string version = boostVersion()); void checkOpenSSL(std::string version);
void checkOpenSSL(std::string version = openSSLVersion());
} // namespace version } // namespace version
} // namespace ripple } // namespace ripple

View File

@@ -157,7 +157,7 @@ SemanticVersion::SemanticVersion (std::string const& version)
throw std::invalid_argument ("invalid version string"); 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 // May not have leading or trailing whitespace
auto left_iter = std::find_if_not (input.begin (), input.end (), auto left_iter = std::find_if_not (input.begin (), input.end (),

View File

@@ -52,7 +52,7 @@ public:
The parsing is as strict as possible. The parsing is as strict as possible.
@return `true` if the string was parsed. @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. */ /** Produce a string from semantic version components. */
std::string print () const; std::string print () const;

View File

@@ -27,51 +27,26 @@ namespace version {
struct CheckLibraryVersions_test : beast::unit_test::suite struct CheckLibraryVersions_test : beast::unit_test::suite
{ {
void print_message() void testBadOpenSSL()
{ {
log << "ssl minimal: " << openSSLMinimal << "\n" testcase ("Out-of-Date OpenSSL");
<< "ssl actual: " << openSSLVersion() << "\n" except ([&]{ checkOpenSSL("0.9.8-o"); });
<< "boost minimal: " << boostMinimal << "\n" except ([&]{ checkOpenSSL("1.0.1-d"); });
<< "boost actual: " << boostVersion() << "\n" except ([&]{ checkOpenSSL("1.0.2-c"); });
<< std::flush;
} }
void test_bad_ssl() void testBadBoost()
{ {
std::string error; testcase ("Out-of-Date Boost");
try { except ([&]{ checkBoost ("1.54.0"); });
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);
} }
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() void run()
{ {
print_message(); unexcept ([&]{ checkLibraryVersions(); });
checkLibraryVersions();
test_bad_ssl(); testBadOpenSSL();
test_bad_boost(); testBadBoost();
} }
}; };