-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
errors: alter and test ERR_TLS_REQUIRED_SERVER_NAME #19988
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -347,18 +347,18 @@ called: | |
* `tlsSocket` {tls.TLSSocket} The `tls.TLSSocket` instance from which the | ||
error originated. | ||
|
||
### server.addContext(hostname, context) | ||
### server.addContext(servername, context) | ||
<!-- YAML | ||
added: v0.5.3 | ||
--> | ||
|
||
* `hostname` {string} A SNI hostname or wildcard (e.g. `'*'`) | ||
* `servername` {string} A SNI hostname or wildcard (e.g. `'*'`) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "hostname" --> "server name", consistent with https://github.com/nodejs/node/blob/master/doc/api/tls.md#event-secureconnection
|
||
* `context` {Object} An object containing any of the possible properties | ||
from the [`tls.createSecureContext()`][] `options` arguments (e.g. `key`, | ||
`cert`, `ca`, etc). | ||
|
||
The `server.addContext()` method adds a secure context that will be used if | ||
the client request's SNI name matches the supplied `hostname` (or wildcard). | ||
the client request's SNI name matches the supplied `severname` (or wildcard). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "severname" -> "servername" (typo) |
||
|
||
### server.address() | ||
<!-- YAML | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,13 +39,13 @@ const { owner_symbol } = require('internal/async_hooks').symbols; | |
const { SecureContext: NativeSecureContext } = internalBinding('crypto'); | ||
const { | ||
ERR_INVALID_ARG_TYPE, | ||
ERR_MISSING_ARGS, | ||
ERR_MULTIPLE_CALLBACK, | ||
ERR_SOCKET_CLOSED, | ||
ERR_TLS_DH_PARAM_SIZE, | ||
ERR_TLS_HANDSHAKE_TIMEOUT, | ||
ERR_TLS_RENEGOTIATE, | ||
ERR_TLS_RENEGOTIATION_DISABLED, | ||
ERR_TLS_REQUIRED_SERVER_NAME, | ||
ERR_TLS_SESSION_ATTACK, | ||
ERR_TLS_SNI_FROM_SERVER | ||
} = require('internal/errors').codes; | ||
|
@@ -1051,7 +1051,7 @@ Server.prototype.setOptions = util.deprecate(function(options) { | |
// SNI Contexts High-Level API | ||
Server.prototype.addContext = function(servername, context) { | ||
if (!servername) { | ||
throw new ERR_TLS_REQUIRED_SERVER_NAME(); | ||
throw new ERR_MISSING_ARGS('servername'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the convention here would be:
to test both the presence of the arg, but also its type. If it's not a string it will throw anyway now just below on the call to |
||
} | ||
|
||
var re = new RegExp('^' + | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -864,10 +864,8 @@ E('ERR_TLS_HANDSHAKE_TIMEOUT', 'TLS handshake timeout', Error); | |
E('ERR_TLS_RENEGOTIATE', 'Attempt to renegotiate TLS session failed', Error); | ||
E('ERR_TLS_RENEGOTIATION_DISABLED', | ||
'TLS session renegotiation disabled for this socket', Error); | ||
|
||
// This should probably be a `TypeError`. | ||
E('ERR_TLS_REQUIRED_SERVER_NAME', | ||
'"servername" is required parameter for Server.addContext', Error); | ||
'"servername" is a required parameter', TypeError); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is now unused and should be removed. |
||
E('ERR_TLS_SESSION_ATTACK', 'TLS session renegotiation attack detected', Error); | ||
E('ERR_TLS_SNI_FROM_SERVER', | ||
'Cannot issue SNI from a TLS server-side socket', Error); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,13 @@ const clientsOptions = [{ | |
const serverResults = []; | ||
const clientResults = []; | ||
|
||
// check for throwing case where servername is not supplied | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Puncutate the comment, please (leading capital, trailing period). |
||
common.expectsError(tls.createServer(serverOptions, () => {}).addContext, { | ||
type: TypeError, | ||
code: 'ERR_MISSING_ARGS', | ||
message: 'The "servername" argument must be specified' | ||
}); | ||
|
||
const server = tls.createServer(serverOptions, function(c) { | ||
serverResults.push(c.servername); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be removed now, as its no longer used.