Skip to content
Snippets Groups Projects
Verified Commit 1f70cee2 authored by Benny Baumann's avatar Benny Baumann
Browse files

Basic interface for using OpenSSL

parent 3de0d359
No related branches found
No related tags found
No related merge requests found
Pipeline #3021 failed
......@@ -5,6 +5,7 @@
#include "lib/ev/ev.hpp"
#include "lib/nl/nl.hpp"
#include "lib/openssl/openssl.hpp"
#include "mumta/evloop.hpp"
......@@ -18,6 +19,9 @@ int main() {
if (!check_version_libnl()) {
return 1;
}
if (!check_version_openssl()) {
return 1;
}
dctl_status_msg("Initializing");
dctl_status_msg("Reading configuration");
......
`pkg-config --cflags --libs libsystemd`
`pkg-config --cflags --libs libnl-3.0`
`pkg-config --cflags --libs libssl libcrypto`
-lev
-pthread
#include "lib/openssl/openssl.hpp"
#include <iomanip>
#include <sstream>
#include <string>
#include <openssl/crypto.h>
#include "service/daemonctl.hpp"
bool check_version_openssl()
{
auto ossl_version{OpenSSL_version_num()};
constexpr auto exp_version{OPENSSL_VERSION_NUMBER};
constexpr auto exp_mask{0xFFFF0000UL};
std::stringstream str;
str <<
"Checking dependency: libssl: detected " <<
std::hex << std::setw(8) << ossl_version <<
", compiled " <<
std::hex << std::setw(8) << ossl_version;
dctl_status_msg(str.str().c_str());
if ((ossl_version & exp_mask) != (exp_version & exp_mask)) {
dctl_status_err("Checking dependency: libssl: failed version check: Major API version mismatch.\n");
return false;
}
if ((ossl_version & ~exp_mask) < (exp_version & ~exp_mask)) {
dctl_status_err("Checking dependency: libssl: failed version check: Minor API version too old.\n");
return false;
}
return true;
}
#pragma once
bool check_version_openssl();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment