Skip to content

Commit a836bcd

Browse files
codebyterenpaun
authored andcommitted
crypto: handle missing OPENSSL_TLS_SECURITY_LEVEL
PR-URL: nodejs/node#58103 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]>
1 parent 462fa63 commit a836bcd

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/ncrypto.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3096,6 +3096,22 @@ std::optional<std::string_view> SSLPointer::getCipherVersion() const {
30963096
return SSL_CIPHER_get_version(cipher);
30973097
}
30983098

3099+
std::optional<int> SSLPointer::getSecurityLevel() {
3100+
#ifndef OPENSSL_IS_BORINGSSL
3101+
auto ctx = SSLCtxPointer::New();
3102+
if (!ctx) return std::nullopt;
3103+
3104+
auto ssl = SSLPointer::New(ctx);
3105+
if (!ssl) return std::nullopt;
3106+
3107+
return SSL_get_security_level(ssl);
3108+
#else
3109+
// OPENSSL_TLS_SECURITY_LEVEL is not defined in BoringSSL
3110+
// so assume it is the default OPENSSL_TLS_SECURITY_LEVEL value.
3111+
return 1;
3112+
#endif // OPENSSL_IS_BORINGSSL
3113+
}
3114+
30993115
SSLCtxPointer::SSLCtxPointer(SSL_CTX* ctx) : ctx_(ctx) {}
31003116

31013117
SSLCtxPointer::SSLCtxPointer(SSLCtxPointer&& other) noexcept

0 commit comments

Comments
 (0)