8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e65ad86 commit 7aa1df7Copy full SHA for 7aa1df7
doc/api/errors.md
@@ -1809,6 +1809,14 @@ recommended to use 2048 bits or larger for stronger security.
1809
A TLS/SSL handshake timed out. In this case, the server must also abort the
1810
connection.
1811
1812
+<a id="ERR_TLS_INVALID_CONTEXT">
1813
+### ERR_TLS_INVALID_CONTEXT
1814
+<!-- YAML
1815
+added: REPLACEME
1816
+-->
1817
+
1818
+The context must be a `SecureContext`.
1819
1820
<a id="ERR_TLS_INVALID_PROTOCOL_METHOD"></a>
1821
### ERR_TLS_INVALID_PROTOCOL_METHOD
1822
lib/_tls_wrap.js
@@ -56,6 +56,7 @@ const {
56
ERR_SOCKET_CLOSED,
57
ERR_TLS_DH_PARAM_SIZE,
58
ERR_TLS_HANDSHAKE_TIMEOUT,
59
+ ERR_TLS_INVALID_CONTEXT,
60
ERR_TLS_RENEGOTIATION_DISABLED,
61
ERR_TLS_REQUIRED_SERVER_NAME,
62
ERR_TLS_SESSION_ATTACK,
@@ -517,8 +518,9 @@ TLSSocket.prototype._wrapHandle = function(wrap) {
517
518
options.credentials ||
519
tls.createSecureContext(options);
520
assert(handle.isStreamBase, 'handle must be a StreamBase');
- assert(context.context instanceof NativeSecureContext,
521
- 'context.context must be a NativeSecureContext');
+ if (!(context.context instanceof NativeSecureContext)) {
522
+ throw new ERR_TLS_INVALID_CONTEXT('context');
523
+ }
524
const res = tls_wrap.wrap(handle, context.context, !!options.isServer);
525
res._parent = handle; // C++ "wrap" object: TCPWrap, JSStream, ...
526
res._parentWrap = wrap; // JS object: net.Socket, JSStreamSocket, ...
lib/internal/errors.js
@@ -1169,6 +1169,7 @@ E('ERR_TLS_CERT_ALTNAME_INVALID', function(reason, host, cert) {
1169
}, Error);
1170
E('ERR_TLS_DH_PARAM_SIZE', 'DH parameter size %s is less than 2048', Error);
1171
E('ERR_TLS_HANDSHAKE_TIMEOUT', 'TLS handshake timeout', Error);
1172
+E('ERR_TLS_INVALID_CONTEXT', '%s must be a SecureContext', TypeError),
1173
E('ERR_TLS_INVALID_PROTOCOL_VERSION',
1174
'%j is not a valid %s TLS protocol version', TypeError);
1175
E('ERR_TLS_PROTOCOL_VERSION_CONFLICT',
test/parallel/test-tls-basic-validations.js
@@ -78,9 +78,13 @@ common.expectsError(
78
assert.throws(() => tls.createServer({ ticketKeys: Buffer.alloc(0) }),
79
/TypeError: Ticket keys length must be 48 bytes/);
80
81
-common.expectsInternalAssertion(
+assert.throws(
82
() => tls.createSecurePair({}),
83
- 'context.context must be a NativeSecureContext'
+ {
84
+ message: 'context must be a SecureContext',
85
+ code: 'ERR_TLS_INVALID_CONTEXT',
86
+ name: 'TypeError',
87
88
);
89
90
{