GeezerVison is showing github.com — tls: use emitWarning() for dhparam < 2048 bits · nodejs/node@d523eb9
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/_tls_common.js +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | 'use strict'; |
2 | 2 |
|
3 | | -const internalUtil = require('internal/util'); |
4 | 3 | const tls = require('tls'); |
5 | 4 |
|
6 | 5 | const SSL_OP_CIPHER_SERVER_PREFERENCE = |
@@ -99,7 +98,7 @@ exports.createSecureContext = function createSecureContext(options, context) { |
99 | 98 | if (options.dhparam) { |
100 | 99 | const warning = c.context.setDHParam(options.dhparam); |
101 | 100 | if (warning) |
102 | | - internalUtil.trace(warning); |
| 101 | + process.emitWarning(warning, 'SecurityWarning'); |
103 | 102 | } |
104 | 103 |
|
105 | 104 | if (options.crl) { |
|
Collapse file
Copy file name to clipboardExpand all lines: lib/internal/util.js -5Lines changed: 0 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | 'use strict'; |
2 | 2 |
|
3 | 3 | const binding = process.binding('util'); |
4 | | -const prefix = `(${process.release.name}:${process.pid}) `; |
5 | 4 |
|
6 | 5 | const kArrowMessagePrivateSymbolIndex = binding['arrow_message_private_symbol']; |
7 | 6 | const kDecoratedPrivateSymbolIndex = binding['decorated_private_symbol']; |
@@ -10,10 +9,6 @@ const kDecoratedPrivateSymbolIndex = binding['decorated_private_symbol']; |
10 | 9 | // `util` module makes it accessible without having to `require('util')` there. |
11 | 10 | exports.customInspectSymbol = Symbol('util.inspect.custom'); |
12 | 11 |
|
13 | | -exports.trace = function(msg) { |
14 | | - console.trace(`${prefix}${msg}`); |
15 | | -}; |
16 | | - |
17 | 12 | // Mark that a method should not be used. |
18 | 13 | // Returns a modified function which warns once by default. |
19 | 14 | // If --no-deprecation is set, then it is a no-op. |
|
Collapse file
Copy file name to clipboardExpand all lines: src/node_crypto.cc +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -933,7 +933,7 @@ void SecureContext::SetDHParam(const FunctionCallbackInfo<Value>& args) { |
933 | 933 | return env->ThrowError("DH parameter is less than 1024 bits"); |
934 | 934 | } else if (size < 2048) { |
935 | 935 | args.GetReturnValue().Set(FIXED_ONE_BYTE_STRING( |
936 | | - env->isolate(), "WARNING: DH parameter is less than 2048 bits")); |
| 936 | + env->isolate(), "DH parameter is less than 2048 bits")); |
937 | 937 | } |
938 | 938 |
|
939 | 939 | SSL_CTX_set_options(sc->ctx_, SSL_OP_SINGLE_DH_USE); |
|
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-tls-dhe.js +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Flags: --no-warnings |
1 | 2 | 'use strict'; |
2 | 3 | const common = require('../common'); |
3 | 4 | const assert = require('assert'); |
@@ -22,6 +23,9 @@ let nsuccess = 0; |
22 | 23 | let ntests = 0; |
23 | 24 | const ciphers = 'DHE-RSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256'; |
24 | 25 |
|
| 26 | +// Test will emit a warning because the DH parameter size is < 2048 bits |
| 27 | +common.expectWarning('SecurityWarning', |
| 28 | + 'DH parameter is less than 2048 bits'); |
25 | 29 |
|
26 | 30 | function loadDHParam(n) { |
27 | 31 | let path = common.fixturesDir; |
|