Skip to content

Commit b867a31

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 nodejs#1739.
1 parent a351777 commit b867a31

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
@@ -804,12 +804,12 @@ void SecureContext::SetDHParam(const FunctionCallbackInfo<Value>& args) {
804804
if (dh == nullptr)
805805
return;
806806

807-
const int keylen = BN_num_bits(dh->p);
808-
if (keylen < 1024) {
809-
DH_free(dh);
807+
const int size = BN_num_bits(dh->p);
808+
if (size < 1024) {
810809
return env->ThrowError("DH parameter is less than 1024 bits");
811-
} else if (keylen < 2048) {
812-
fprintf(stderr, "WARNING: DH parameter is less than 2048 bits\n");
810+
} else if (size < 2048) {
811+
args.GetReturnValue().Set(FIXED_ONE_BYTE_STRING(
812+
env->isolate(), "WARNING: DH parameter is less than 2048 bits"));
813813
}
814814

815815
SSL_CTX_set_options(sc->ctx_, SSL_OP_SINGLE_DH_USE);

0 commit comments

Comments
 (0)