Browse Source

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: https://github.com/nodejs/node/pull/1831
Reviewed-By: indutny - Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
v5.x
Shigeki Ohtsu 10 years ago
parent
commit
0140e1b5e3
  1. 6
      lib/_tls_common.js
  2. 10
      src/node_crypto.cc

6
lib/_tls_common.js

@ -99,7 +99,11 @@ exports.createSecureContext = function createSecureContext(options, context) {
else if (options.ecdhCurve)
c.context.setECDHCurve(options.ecdhCurve);
if (options.dhparam) c.context.setDHParam(options.dhparam);
if (options.dhparam) {
var warning = c.context.setDHParam(options.dhparam);
if (warning)
console.trace(warning);
}
if (options.crl) {
if (Array.isArray(options.crl)) {

10
src/node_crypto.cc

@ -797,12 +797,12 @@ void SecureContext::SetDHParam(const FunctionCallbackInfo<Value>& args) {
if (dh == nullptr)
return;
const int keylen = BN_num_bits(dh->p);
if (keylen < 1024) {
DH_free(dh);
const int size = BN_num_bits(dh->p);
if (size < 1024) {
return env->ThrowError("DH parameter is less than 1024 bits");
} else if (keylen < 2048) {
fprintf(stderr, "WARNING: DH parameter is less than 2048 bits\n");
} else if (size < 2048) {
args.GetReturnValue().Set(FIXED_ONE_BYTE_STRING(
env->isolate(), "WARNING: DH parameter is less than 2048 bits"));
}
SSL_CTX_set_options(sc->ctx_, SSL_OP_SINGLE_DH_USE);

Loading…
Cancel
Save