Skip to content

Commit

Permalink
src: fix dynamically linked OpenSSL version
Browse files Browse the repository at this point in the history
Report the version of OpenSSL that Node.js is running with instead
of the version of OpenSSL that Node.js was compiled against.

PR-URL: #53456
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
  • Loading branch information
richardlau authored and marco-ippolito committed Jul 19, 2024
1 parent 7551bd2 commit 10a1380
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/node_metadata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#endif // NODE_BUNDLED_ZLIB

#if HAVE_OPENSSL
#include <openssl/opensslv.h>
#include <openssl/crypto.h>
#if NODE_OPENSSL_HAS_QUIC
#include <openssl/quic.h>
#endif
Expand Down Expand Up @@ -54,9 +54,10 @@ static constexpr size_t search(const char* s, char c, size_t n = 0) {
static inline std::string GetOpenSSLVersion() {
// sample openssl version string format
// for reference: "OpenSSL 1.1.0i 14 Aug 2018"
constexpr size_t start = search(OPENSSL_VERSION_TEXT, ' ') + 1;
constexpr size_t len = search(&OPENSSL_VERSION_TEXT[start], ' ');
return std::string(OPENSSL_VERSION_TEXT, start, len);
const char* version = OpenSSL_version(OPENSSL_VERSION);
const size_t start = search(version, ' ') + 1;
const size_t len = search(&version[start], ' ');
return std::string(version, start, len);
}
#endif // HAVE_OPENSSL

Expand Down

0 comments on commit 10a1380

Please sign in to comment.