CLI: Add OpenSSL version to 'Build' section in --version

This helps to see against which OpenSSL version Icinga was built.
Inspired by #5572
This commit is contained in:
Michael Friedrich 2020-02-13 15:25:03 +01:00
parent be2178b993
commit 71c7eebe4e
3 changed files with 16 additions and 1 deletions

View File

@ -14,6 +14,7 @@
#include "base/convert.hpp"
#include "base/scriptglobal.hpp"
#include "base/process.hpp"
#include "base/tlsutility.hpp"
#include <boost/algorithm/string/trim.hpp>
#include <boost/exception/errinfo_api_function.hpp>
#include <boost/exception/errinfo_errno.hpp>
@ -551,7 +552,8 @@ void Application::DisplayInfoMessage(std::ostream& os, bool skipVersion)
os << "\nBuild information:\n"
<< " Compiler: " << systemNS->Get("BuildCompilerName") << " " << systemNS->Get("BuildCompilerVersion") << "\n"
<< " Build host: " << systemNS->Get("BuildHostName") << "\n";
<< " Build host: " << systemNS->Get("BuildHostName") << "\n"
<< " OpenSSL version: " << GetOpenSSLVersion() << "\n";
os << "\nApplication information:\n"
<< "\nGeneral paths:\n"

View File

@ -8,6 +8,8 @@
#include "base/application.hpp"
#include "base/exception.hpp"
#include <boost/asio/ssl/context.hpp>
#include <openssl/opensslv.h>
#include <openssl/crypto.h>
#include <fstream>
namespace icinga
@ -17,6 +19,15 @@ static bool l_SSLInitialized = false;
static boost::mutex *l_Mutexes;
static boost::mutex l_RandomMutex;
String GetOpenSSLVersion()
{
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
return OpenSSL_version(OPENSSL_VERSION);
#else /* OPENSSL_VERSION_NUMBER >= 0x10100000L */
return SSLeay_version(SSLEAY_VERSION);
#endif /* OPENSSL_VERSION_NUMBER >= 0x10100000L */
}
#ifdef CRYPTO_LOCK
static void OpenSSLLockingCallback(int mode, int type, const char *, int)
{

View File

@ -23,6 +23,8 @@ namespace icinga
void InitializeOpenSSL();
String GetOpenSSLVersion();
Shared<boost::asio::ssl::context>::Ptr MakeAsioSslContext(const String& pubkey = String(), const String& privkey = String(), const String& cakey = String());
void AddCRLToSSLContext(const Shared<boost::asio::ssl::context>::Ptr& context, const String& crlPath);
void SetCipherListToSSLContext(const Shared<boost::asio::ssl::context>::Ptr& context, const String& cipherList);