From 81e70d717aef0db8841d85740df0101a9404dfd7 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Thu, 11 Jul 2024 13:06:22 +0200 Subject: [PATCH] fix: do not try to use OpenSSL when building for Electron --- addon/openssl-crypto.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/addon/openssl-crypto.cc b/addon/openssl-crypto.cc index 8d8d976..deb9012 100644 --- a/addon/openssl-crypto.cc +++ b/addon/openssl-crypto.cc @@ -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 #include #include @@ -13,8 +19,6 @@ #include -#include "mongocrypt.h" - #ifdef _WIN32 #include #else @@ -441,3 +445,13 @@ std::unique_ptr createOpenSSLCryptoHooks() { } // namespace opensslcrypto } // namespace node_mongocrypt + +#else // ELECTRON_ENSURE_CONFIG_GYPI +namespace node_mongocrypt { +namespace opensslcrypto { +std::unique_ptr createOpenSSLCryptoHooks() { + return {}; +} +} +} +#endif // ELECTRON_ENSURE_CONFIG_GYPI