Skip to content

Commit 484262e

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.
1 parent 9c74500 commit 484262e

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/_tls_common.js

Lines changed: 5 additions & 1 deletion
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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,8 @@ void SecureContext::SetDHParam(const FunctionCallbackInfo<Value>& args) {
761761
if (keylen < 1024)
762762
return env->ThrowError("DH parameter is less than 1024 bits");
763763
else if (keylen < 2048)
764-
fprintf(stderr, "WARNING: DH parameter is less than 2048 bits\n");
764+
args.GetReturnValue().Set(FIXED_ONE_BYTE_STRING(
765+
env->isolate(), "WARNING: DH parameter is less than 2048 bits"));
765766

766767
SSL_CTX_set_options(sc->ctx_, SSL_OP_SINGLE_DH_USE);
767768
int r = SSL_CTX_set_tmp_dh(sc->ctx_, dh);

0 commit comments

Comments
 (0)