Skip to content

Commit 0140e1b

Browse files
author
Shigeki Ohtsu
committed
tls: output warning of setDHParam to console.trace
To make it easy to figure out where the warning comes from. Also fix style and variable name that was made in #1739. PR-URL: #1831 Reviewed-By: indutny - Fedor Indutny <[email protected]> Reviewed-By: bnoordhuis - Ben Noordhuis <[email protected]>
1 parent f72e178 commit 0140e1b

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

lib/_tls_common.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ exports.createSecureContext = function createSecureContext(options, context) {
9999
else if (options.ecdhCurve)
100100
c.context.setECDHCurve(options.ecdhCurve);
101101

102-
if (options.dhparam) c.context.setDHParam(options.dhparam);
102+
if (options.dhparam) {
103+
var warning = c.context.setDHParam(options.dhparam);
104+
if (warning)
105+
console.trace(warning);
106+
}
103107

104108
if (options.crl) {
105109
if (Array.isArray(options.crl)) {

src/node_crypto.cc

+5-5
Original file line numberDiff line numberDiff line change
@@ -797,12 +797,12 @@ void SecureContext::SetDHParam(const FunctionCallbackInfo<Value>& args) {
797797
if (dh == nullptr)
798798
return;
799799

800-
const int keylen = BN_num_bits(dh->p);
801-
if (keylen < 1024) {
802-
DH_free(dh);
800+
const int size = BN_num_bits(dh->p);
801+
if (size < 1024) {
803802
return env->ThrowError("DH parameter is less than 1024 bits");
804-
} else if (keylen < 2048) {
805-
fprintf(stderr, "WARNING: DH parameter is less than 2048 bits\n");
803+
} else if (size < 2048) {
804+
args.GetReturnValue().Set(FIXED_ONE_BYTE_STRING(
805+
env->isolate(), "WARNING: DH parameter is less than 2048 bits"));
806806
}
807807

808808
SSL_CTX_set_options(sc->ctx_, SSL_OP_SINGLE_DH_USE);

0 commit comments

Comments
 (0)