Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cherry 4.0.x]: Explicitly initialize ssl #1674

Open
wants to merge 2 commits into
base: 4.0.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/common/crypto/platform/openssl/crypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <openssl/err.h>
#include <openssl/engine.h>
#include <openssl/ui.h>
#include <openssl/ssl.h>
#ifndef MENDER_CRYPTO_OPENSSL_LEGACY
#include <openssl/provider.h>
#include <openssl/store.h>
Expand Down Expand Up @@ -282,8 +283,15 @@ ExpectedPrivateKey LoadFrom(const Args &args) {
#endif // ndef MENDER_CRYPTO_OPENSSL_LEGACY

ExpectedPrivateKey PrivateKey::Load(const Args &args) {
// Numerous internal OpenSSL functions call OPENSSL_init_ssl().
// Therefore, in order to perform nondefault initialisation,
// OPENSSL_init_ssl() MUST be called by application code prior to any other OpenSSL function
// calls. See: https://docs.openssl.org/3.3/man3/OPENSSL_init_ssl/#description
if (OPENSSL_init_ssl(0, nullptr) != OPENSSL_SUCCESS) {
log::Warning("Error initializing libssl: " + GetOpenSSLErrorMessage());
}
// Load OpenSSL config
if ((CONF_modules_load_file(nullptr, nullptr, 0) != OPENSSL_SUCCESS)) {
if (CONF_modules_load_file(nullptr, nullptr, 0) != OPENSSL_SUCCESS) {
log::Warning("Failed to load OpenSSL configuration file: " + GetOpenSSLErrorMessage());
}

Expand Down