Skip to content
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

tls: deprecate Server.prototype.setOptions() #23820

Merged
merged 1 commit into from
Oct 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -2279,6 +2279,20 @@ and `cluster` modules on Windows. The function is not generally useful and
is being removed. See discussion here:
https://github.com/nodejs/node/issues/18391

<a id="DEP0122"></a>
### DEP0122: tls Server.prototype.setOptions()
<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/23820
description: Runtime deprecation.
-->

Type: Runtime

Please use `Server.prototype.setSecureContext()` instead.


[`--pending-deprecation`]: cli.html#cli_pending_deprecation
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size
[`Buffer.from(array)`]: buffer.html#buffer_class_method_buffer_from_array
Expand Down
21 changes: 12 additions & 9 deletions lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -827,16 +827,19 @@ function Server(options, listener) {
throw new ERR_INVALID_ARG_TYPE('options', 'Object', options);
}


this._contexts = [];
this.requestCert = options.requestCert === true;
this.rejectUnauthorized = options.rejectUnauthorized !== false;

// Handle option defaults:
this.setOptions(options);
if (options.sessionTimeout)
this.sessionTimeout = options.sessionTimeout;

if (options.ticketKeys)
this.ticketKeys = options.ticketKeys;

if (options.ALPNProtocols)
tls.convertALPNProtocols(options.ALPNProtocols, this);

// setSecureContext() overlaps with setOptions() quite a bit. setOptions()
// is an undocumented API that was probably never intended to be exposed
// publicly. Unfortunately, it would be a breaking change to just remove it,
// and there is at least one test that depends on it.
this.setSecureContext(options);

this[kHandshakeTimeout] = options.handshakeTimeout || (120 * 1000);
Expand Down Expand Up @@ -998,7 +1001,7 @@ Server.prototype.setTicketKeys = function setTicketKeys(keys) {
};


Server.prototype.setOptions = function(options) {
Server.prototype.setOptions = util.deprecate(function(options) {
this.requestCert = options.requestCert === true;
this.rejectUnauthorized = options.rejectUnauthorized !== false;

Expand Down Expand Up @@ -1033,7 +1036,7 @@ Server.prototype.setOptions = function(options) {
.digest('hex')
.slice(0, 32);
}
};
}, 'Server.prototype.setOptions() is deprecated', 'DEP0122');

// SNI Contexts High-Level API
Server.prototype.addContext = function(servername, context) {
Expand Down
3 changes: 3 additions & 0 deletions test/parallel/test-tls-server-setoptions-clientcertengine.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ const tls = require('tls');
{
const server = tls.createServer();
assert.strictEqual(server.clientCertEngine, undefined);
common.expectWarning('DeprecationWarning',
'Server.prototype.setOptions() is deprecated',
'DEP0122');
server.setOptions({ clientCertEngine: 'Cannonmouth' });
assert.strictEqual(server.clientCertEngine, 'Cannonmouth');
}