Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d523eb9

Browse filesBrowse files
committed
tls: use emitWarning() for dhparam < 2048 bits
When a dhparam less than 2048 bits was used, a warning was being printed directly to console.error using an internalUtil.trace function that was not used anywhere else. This replaces it with a proper process warning and removes the internalUtil.trace function. PR-URL: #11447 Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rod Vagg <rod@vagg.org>
1 parent 0510472 commit d523eb9
Copy full SHA for d523eb9

File tree

Expand file treeCollapse file tree

4 files changed

+6
-8
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+6
-8
lines changed
Open diff view settings
Collapse file

‎lib/_tls_common.js‎

Copy file name to clipboardExpand all lines: lib/_tls_common.js
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

3-
const internalUtil = require('internal/util');
43
const tls = require('tls');
54

65
const SSL_OP_CIPHER_SERVER_PREFERENCE =
@@ -99,7 +98,7 @@ exports.createSecureContext = function createSecureContext(options, context) {
9998
if (options.dhparam) {
10099
const warning = c.context.setDHParam(options.dhparam);
101100
if (warning)
102-
internalUtil.trace(warning);
101+
process.emitWarning(warning, 'SecurityWarning');
103102
}
104103

105104
if (options.crl) {
Collapse file

‎lib/internal/util.js‎

Copy file name to clipboardExpand all lines: lib/internal/util.js
-5Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
const binding = process.binding('util');
4-
const prefix = `(${process.release.name}:${process.pid}) `;
54

65
const kArrowMessagePrivateSymbolIndex = binding['arrow_message_private_symbol'];
76
const kDecoratedPrivateSymbolIndex = binding['decorated_private_symbol'];
@@ -10,10 +9,6 @@ const kDecoratedPrivateSymbolIndex = binding['decorated_private_symbol'];
109
// `util` module makes it accessible without having to `require('util')` there.
1110
exports.customInspectSymbol = Symbol('util.inspect.custom');
1211

13-
exports.trace = function(msg) {
14-
console.trace(`${prefix}${msg}`);
15-
};
16-
1712
// Mark that a method should not be used.
1813
// Returns a modified function which warns once by default.
1914
// If --no-deprecation is set, then it is a no-op.
Collapse file

‎src/node_crypto.cc‎

Copy file name to clipboardExpand all lines: src/node_crypto.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ void SecureContext::SetDHParam(const FunctionCallbackInfo<Value>& args) {
933933
return env->ThrowError("DH parameter is less than 1024 bits");
934934
} else if (size < 2048) {
935935
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"));
937937
}
938938

939939
SSL_CTX_set_options(sc->ctx_, SSL_OP_SINGLE_DH_USE);
Collapse file

‎test/parallel/test-tls-dhe.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-tls-dhe.js
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Flags: --no-warnings
12
'use strict';
23
const common = require('../common');
34
const assert = require('assert');
@@ -22,6 +23,9 @@ let nsuccess = 0;
2223
let ntests = 0;
2324
const ciphers = 'DHE-RSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';
2425

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');
2529

2630
function loadDHParam(n) {
2731
let path = common.fixturesDir;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.