Skip to content

Commit

Permalink
fix: do not try to use OpenSSL when building for Electron
Browse files Browse the repository at this point in the history
  • Loading branch information
addaleax committed Jul 11, 2024
1 parent b010fa9 commit 81e70d7
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions addon/openssl-crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
// This file provides native crypto hooks for OpenSSL 3 (the default since Node.js 18),
// allowing us to skip expensive round-trips between JS and C++.

#include "mongocrypt.h"

// Electron does not expose OpenSSL, so we cannot use OpenSSL
// functions directly if we're building against Electron:
// https://github.com/electron/electron/issues/13176
#ifndef ELECTRON_ENSURE_CONFIG_GYPI
#include <openssl/crypto.h>
#include <openssl/err.h>
#include <openssl/evp.h>
Expand All @@ -13,8 +19,6 @@

#include <stdexcept>

#include "mongocrypt.h"

#ifdef _WIN32
#include <windows.h>
#else
Expand Down Expand Up @@ -441,3 +445,13 @@ std::unique_ptr<CryptoHooks> createOpenSSLCryptoHooks() {

} // namespace opensslcrypto
} // namespace node_mongocrypt

#else // ELECTRON_ENSURE_CONFIG_GYPI
namespace node_mongocrypt {
namespace opensslcrypto {
std::unique_ptr<CryptoHooks> createOpenSSLCryptoHooks() {
return {};
}
}
}
#endif // ELECTRON_ENSURE_CONFIG_GYPI

0 comments on commit 81e70d7

Please sign in to comment.