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: runtime deprecate _tls_legacy #11349

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 8 additions & 0 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,14 @@ deprecated. Please use `ServerResponse.prototype.writeHead()` instead.
*Note*: The `ServerResponse.prototype.writeHeader()` method was never documented
as an officially supported API.

<a id="DEP0064"></a>
### DEP0064: tls.createSecurePair()

Type: Runtime

The `tls.createSecurePair()` API was deprecated in documentation in Node.js
0.11.3. Users should use `tls.Socket` instead.

[alloc]: buffer.html#buffer_class_method_buffer_alloc_size_fill_encoding
[alloc_unsafe_size]: buffer.html#buffer_class_method_buffer_allocunsafe_size
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size
Expand Down
39 changes: 21 additions & 18 deletions lib/_tls_legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
require('internal/util').assertCrypto();

const assert = require('assert');
const Buffer = require('buffer').Buffer;
const common = require('_tls_common');
const Connection = process.binding('crypto').Connection;
const EventEmitter = require('events');
const internalUtil = require('internal/util');
const stream = require('stream');
const Timer = process.binding('timer_wrap').Timer;
const tls = require('tls');
const util = require('util');
const common = require('_tls_common');

const debug = util.debuglog('tls-legacy');
const Buffer = require('buffer').Buffer;
const Timer = process.binding('timer_wrap').Timer;
const Connection = process.binding('crypto').Connection;

function SlabBuffer() {
this.create();
Expand Down Expand Up @@ -787,18 +789,11 @@ function securePairNT(self, options) {
}


exports.createSecurePair = function(context,
isServer,
requestCert,
rejectUnauthorized,
options) {
var pair = new SecurePair(context,
isServer,
requestCert,
rejectUnauthorized,
options);
return pair;
};
function createSecurePair(context, isServer, requestCert,
rejectUnauthorized, options) {
return new SecurePair(context, isServer, requestCert,
rejectUnauthorized, options);
}


SecurePair.prototype.maybeInitFinished = function() {
Expand Down Expand Up @@ -868,7 +863,7 @@ SecurePair.prototype.error = function(returnOnly) {
};


exports.pipe = function pipe(pair, socket) {
function pipe(pair, socket) {
pair.encrypted.pipe(socket);
socket.pipe(pair.encrypted);

Expand Down Expand Up @@ -918,7 +913,7 @@ exports.pipe = function pipe(pair, socket) {
socket.on('timeout', ontimeout);

return cleartext;
};
}


function pipeCloseNT(pair, socket) {
Expand All @@ -927,3 +922,11 @@ function pipeCloseNT(pair, socket) {
pair.encrypted.unpipe(socket);
socket.destroySoon();
}

module.exports = {
createSecurePair:
internalUtil.deprecate(createSecurePair,
'tls.createSecurePair() is deprecated. Please use ' +
'tls.Socket instead.', 'DEP0064'),
pipe
};
2 changes: 2 additions & 0 deletions lib/tls.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,6 @@ exports.TLSSocket = require('_tls_wrap').TLSSocket;
exports.Server = require('_tls_wrap').Server;
exports.createServer = require('_tls_wrap').createServer;
exports.connect = require('_tls_wrap').connect;

// Deprecated: DEP0064
exports.createSecurePair = require('_tls_legacy').createSecurePair;
12 changes: 12 additions & 0 deletions test/parallel/test-tls-legacy-deprecated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Flags: --no-warnings
'use strict';
const common = require('../common');
const assert = require('assert');
const tls = require('tls');

common.expectWarning(
'DeprecationWarning',
'tls.createSecurePair() is deprecated. Please use tls.Socket instead.'
);

assert.doesNotThrow(() => tls.createSecurePair());