From c187b2315c16127ddad5259ad80de4f8101fe161 Mon Sep 17 00:00:00 2001 From: Shubham Mittal <107728331+smittals2@users.noreply.github.com> Date: Wed, 20 Mar 2024 10:11:55 -0700 Subject: [PATCH] Adding No-op functions required for NodeJS compatability (#1474) ### Description of changes: Added OPENSSL_init and SSL_CTX_set_dh_auto as no-op functions to support compilation with NodeJS. OPENSSL_init does nothing by design and SSL_CTX_set_dh_auto because DH is not supported with SSL in AWS-LC. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license. --- crypto/crypto.c | 2 ++ include/openssl/crypto.h | 3 +++ include/openssl/ssl.h | 3 +++ ssl/ssl_lib.cc | 4 ++++ 4 files changed, 12 insertions(+) diff --git a/crypto/crypto.c b/crypto/crypto.c index 578f5ebb35..4aa9d1276c 100644 --- a/crypto/crypto.c +++ b/crypto/crypto.c @@ -153,4 +153,6 @@ int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings) { return 1; } +void OPENSSL_init(void) {} + void OPENSSL_cleanup(void) {} diff --git a/include/openssl/crypto.h b/include/openssl/crypto.h index ec7219a8a0..bb1be29a40 100644 --- a/include/openssl/crypto.h +++ b/include/openssl/crypto.h @@ -177,6 +177,9 @@ OPENSSL_EXPORT void OPENSSL_load_builtin_modules(void); OPENSSL_EXPORT int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings); +// OPENSSL_init does nothing. +OPENSSL_EXPORT void OPENSSL_init(void); + // OPENSSL_cleanup does nothing. OPENSSL_EXPORT void OPENSSL_cleanup(void); diff --git a/include/openssl/ssl.h b/include/openssl/ssl.h index 7bcef522c1..bbd02d1549 100644 --- a/include/openssl/ssl.h +++ b/include/openssl/ssl.h @@ -5159,6 +5159,9 @@ OPENSSL_EXPORT void SSL_set_tmp_dh_callback(SSL *ssl, DH *(*cb)(SSL *ssl, int is_export, int keylength)); +// SSL_CTX_set_dh_auto does nothing and returns 0 for error. +OPENSSL_EXPORT long SSL_CTX_set_dh_auto(SSL_CTX *ctx, int onoff); + // SSL_CTX_set1_sigalgs takes |num_values| ints and interprets them as pairs // where the first is the nid of a hash function and the second is an // |EVP_PKEY_*| value. It configures the signature algorithm preferences for diff --git a/ssl/ssl_lib.cc b/ssl/ssl_lib.cc index 1069db2017..e48415bea0 100644 --- a/ssl/ssl_lib.cc +++ b/ssl/ssl_lib.cc @@ -2760,6 +2760,10 @@ void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx, void SSL_set_tmp_dh_callback(SSL *ssl, DH *(*cb)(SSL *ssl, int is_export, int keylength)) {} +long SSL_CTX_set_dh_auto(SSL_CTX *ctx, int onoff) { + return 0; +} + static int use_psk_identity_hint(UniquePtr *out, const char *identity_hint) { if (identity_hint != NULL && strlen(identity_hint) > PSK_MAX_IDENTITY_LEN) {