summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/node_crypto.cc2
-rw-r--r--src/node_crypto.h2
-rw-r--r--src/node_crypto_bio.cc2
-rw-r--r--src/node_crypto_bio.h2
4 files changed, 8 insertions, 0 deletions
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
index adbfaaf98e..7f5544b8f2 100644
--- a/src/node_crypto.cc
+++ b/src/node_crypto.cc
@@ -5141,6 +5141,8 @@ void InitCryptoOnce() {
ERR_load_ENGINE_strings();
ENGINE_load_builtin_engines();
#endif // !OPENSSL_NO_ENGINE
+
+ NodeBIO::GetMethod();
}
diff --git a/src/node_crypto.h b/src/node_crypto.h
index ee069c9cf7..269bccbc03 100644
--- a/src/node_crypto.h
+++ b/src/node_crypto.h
@@ -97,6 +97,8 @@ extern int VerifyCallback(int preverify_ok, X509_STORE_CTX* ctx);
extern void UseExtraCaCerts(const std::string& file);
+void InitCryptoOnce();
+
class SecureContext : public BaseObject {
public:
~SecureContext() override {
diff --git a/src/node_crypto_bio.cc b/src/node_crypto_bio.cc
index ab68c0a081..baa90204f2 100644
--- a/src/node_crypto_bio.cc
+++ b/src/node_crypto_bio.cc
@@ -247,6 +247,8 @@ const BIO_METHOD* NodeBIO::GetMethod() {
return &method;
#else
+ // This is called from InitCryptoOnce() to avoid race conditions during
+ // initialization.
static BIO_METHOD* method = nullptr;
if (method == nullptr) {
diff --git a/src/node_crypto_bio.h b/src/node_crypto_bio.h
index fefd097b32..0c61f19d01 100644
--- a/src/node_crypto_bio.h
+++ b/src/node_crypto_bio.h
@@ -164,6 +164,8 @@ class NodeBIO : public MemoryRetainer {
int eof_return_ = -1;
Buffer* read_head_ = nullptr;
Buffer* write_head_ = nullptr;
+
+ friend void node::crypto::InitCryptoOnce();
};
} // namespace crypto