GeezerVison is showing github.com — tls: add unsupported renegotiation error · nodejs/node@94e5f63
File treeExpand 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: doc/api/errors.md +7Lines changed: 7 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -3084,6 +3084,13 @@ Failed to set PSK identity hint. Hint may be too long. | 3084 | 3084 | An attempt was made to renegotiate TLS on a socket instance with renegotiation | 3085 | 3085 | disabled. | 3086 | 3086 |
| | 3087 | +<a id="ERR_TLS_RENEGOTIATION_UNSUPPORTED"></a> | | 3088 | + | | 3089 | +### `ERR_TLS_RENEGOTIATION_UNSUPPORTED` | | 3090 | + | | 3091 | +An attempt was made to renegotiate TLS, but the TLS implementation does not | | 3092 | +support caller-initiated renegotiation. | | 3093 | + | 3087 | 3094 | <a id="ERR_TLS_REQUIRED_SERVER_NAME"></a> | 3088 | 3095 |
| 3089 | 3096 | ### `ERR_TLS_REQUIRED_SERVER_NAME` | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/errors.js +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1827,6 +1827,8 @@ E('ERR_TLS_PROTOCOL_VERSION_CONFLICT', | 1827 | 1827 | 'TLS protocol version %j conflicts with secureProtocol %j', TypeError); | 1828 | 1828 | E('ERR_TLS_RENEGOTIATION_DISABLED', | 1829 | 1829 | 'TLS session renegotiation disabled for this socket', Error); | | 1830 | +E('ERR_TLS_RENEGOTIATION_UNSUPPORTED', | | 1831 | + 'TLS session renegotiation is unsupported by this TLS implementation', Error); | 1830 | 1832 |
| 1831 | 1833 | // This should probably be a `TypeError`. | 1832 | 1834 | E('ERR_TLS_REQUIRED_SERVER_NAME', | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/tls/wrap.js +7-1Lines changed: 7 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -72,6 +72,7 @@ const { | 72 | 72 | ERR_TLS_INVALID_CONTEXT, | 73 | 73 | ERR_TLS_INVALID_STATE, | 74 | 74 | ERR_TLS_RENEGOTIATION_DISABLED, | | 75 | + ERR_TLS_RENEGOTIATION_UNSUPPORTED, | 75 | 76 | ERR_TLS_REQUIRED_SERVER_NAME, | 76 | 77 | ERR_TLS_SESSION_ATTACK, | 77 | 78 | ERR_TLS_SNI_FROM_SERVER, | @@ -1092,8 +1093,13 @@ TLSSocket.prototype.renegotiate = function(options, callback) { | 1092 | 1093 | try { | 1093 | 1094 | this._handle.renegotiate(); | 1094 | 1095 | } catch (err) { | | 1096 | + const isBoringSSLRenegotiationUnsupported = | | 1097 | + process.features.openssl_is_boringssl && | | 1098 | + err?.code === 'ERR_SSL_FUNCTION_SHOULD_NOT_HAVE_BEEN_CALLED'; | | 1099 | + const error = isBoringSSLRenegotiationUnsupported ? | | 1100 | + new ERR_TLS_RENEGOTIATION_UNSUPPORTED() : err; | 1095 | 1101 | if (callback) { | 1096 | | - process.nextTick(callback, err); | | 1102 | + process.nextTick(callback, error); | 1097 | 1103 | } | 1098 | 1104 | return false; | 1099 | 1105 | } | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-tls-client-renegotiation-13.js +16-8Lines changed: 16 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -32,14 +32,22 @@ connect({ | 32 | 32 | assert.strictEqual(client.getProtocol(), 'TLSv1.3'); | 33 | 33 |
| 34 | 34 | const ok = client.renegotiate({}, common.mustCall((err) => { | 35 | | - assert.throws(() => { throw err; }, { | 36 | | - message: hasOpenSSL3 ? | 37 | | - 'error:0A00010A:SSL routines::wrong ssl version' : | 38 | | - 'error:1420410A:SSL routines:SSL_renegotiate:wrong ssl version', | 39 | | - code: 'ERR_SSL_WRONG_SSL_VERSION', | 40 | | - library: 'SSL routines', | 41 | | - reason: 'wrong ssl version', | 42 | | - }); | | 35 | + if (process.features.openssl_is_boringssl) { | | 36 | + assert.throws(() => { throw err; }, { | | 37 | + message: 'TLS session renegotiation is unsupported by this TLS ' + | | 38 | + 'implementation', | | 39 | + code: 'ERR_TLS_RENEGOTIATION_UNSUPPORTED', | | 40 | + }); | | 41 | + } else { | | 42 | + assert.throws(() => { throw err; }, { | | 43 | + message: hasOpenSSL3 ? | | 44 | + 'error:0A00010A:SSL routines::wrong ssl version' : | | 45 | + 'error:1420410A:SSL routines:SSL_renegotiate:wrong ssl version', | | 46 | + code: 'ERR_SSL_WRONG_SSL_VERSION', | | 47 | + library: 'SSL routines', | | 48 | + reason: 'wrong ssl version', | | 49 | + }); | | 50 | + } | 43 | 51 | cleanup(); | 44 | 52 | })); | 45 | 53 |
| |
|