Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a2ae089

Browse filesBrowse files
committed
tls: runtime deprecation for tls.createSecurePair()
Upgrade the deprecation for _tls_legacy (`tls.createSecurePair()`) to a runtime deprecation. PR-URL: #11349 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
1 parent cd3c478 commit a2ae089
Copy full SHA for a2ae089

File tree

Expand file treeCollapse file tree

4 files changed

+43
-18
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+43
-18
lines changed
Open diff view settings
Collapse file

‎doc/api/deprecations.md‎

Copy file name to clipboardExpand all lines: doc/api/deprecations.md
+8Lines changed: 8 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,14 @@ deprecated. Please use `ServerResponse.prototype.writeHead()` instead.
534534
*Note*: The `ServerResponse.prototype.writeHeader()` method was never documented
535535
as an officially supported API.
536536

537+
<a id="DEP0064"></a>
538+
### DEP0064: tls.createSecurePair()
539+
540+
Type: Runtime
541+
542+
The `tls.createSecurePair()` API was deprecated in documentation in Node.js
543+
0.11.3. Users should use `tls.Socket` instead.
544+
537545
[alloc]: buffer.html#buffer_class_method_buffer_alloc_size_fill_encoding
538546
[alloc_unsafe_size]: buffer.html#buffer_class_method_buffer_allocunsafe_size
539547
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size
Collapse file

‎lib/_tls_legacy.js‎

Copy file name to clipboardExpand all lines: lib/_tls_legacy.js
+21-18Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
require('internal/util').assertCrypto();
44

55
const assert = require('assert');
6+
const Buffer = require('buffer').Buffer;
7+
const common = require('_tls_common');
8+
const Connection = process.binding('crypto').Connection;
69
const EventEmitter = require('events');
10+
const internalUtil = require('internal/util');
711
const stream = require('stream');
12+
const Timer = process.binding('timer_wrap').Timer;
813
const tls = require('tls');
914
const util = require('util');
10-
const common = require('_tls_common');
15+
1116
const debug = util.debuglog('tls-legacy');
12-
const Buffer = require('buffer').Buffer;
13-
const Timer = process.binding('timer_wrap').Timer;
14-
const Connection = process.binding('crypto').Connection;
1517

1618
function SlabBuffer() {
1719
this.create();
@@ -787,18 +789,11 @@ function securePairNT(self, options) {
787789
}
788790

789791

790-
exports.createSecurePair = function(context,
791-
isServer,
792-
requestCert,
793-
rejectUnauthorized,
794-
options) {
795-
var pair = new SecurePair(context,
796-
isServer,
797-
requestCert,
798-
rejectUnauthorized,
799-
options);
800-
return pair;
801-
};
792+
function createSecurePair(context, isServer, requestCert,
793+
rejectUnauthorized, options) {
794+
return new SecurePair(context, isServer, requestCert,
795+
rejectUnauthorized, options);
796+
}
802797

803798

804799
SecurePair.prototype.maybeInitFinished = function() {
@@ -868,7 +863,7 @@ SecurePair.prototype.error = function(returnOnly) {
868863
};
869864

870865

871-
exports.pipe = function pipe(pair, socket) {
866+
function pipe(pair, socket) {
872867
pair.encrypted.pipe(socket);
873868
socket.pipe(pair.encrypted);
874869

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

920915
return cleartext;
921-
};
916+
}
922917

923918

924919
function pipeCloseNT(pair, socket) {
@@ -927,3 +922,11 @@ function pipeCloseNT(pair, socket) {
927922
pair.encrypted.unpipe(socket);
928923
socket.destroySoon();
929924
}
925+
926+
module.exports = {
927+
createSecurePair:
928+
internalUtil.deprecate(createSecurePair,
929+
'tls.createSecurePair() is deprecated. Please use ' +
930+
'tls.Socket instead.', 'DEP0064'),
931+
pipe
932+
};
Collapse file

‎lib/tls.js‎

Copy file name to clipboardExpand all lines: lib/tls.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,4 +235,6 @@ exports.TLSSocket = require('_tls_wrap').TLSSocket;
235235
exports.Server = require('_tls_wrap').Server;
236236
exports.createServer = require('_tls_wrap').createServer;
237237
exports.connect = require('_tls_wrap').connect;
238+
239+
// Deprecated: DEP0064
238240
exports.createSecurePair = require('_tls_legacy').createSecurePair;
Collapse file
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Flags: --no-warnings
2+
'use strict';
3+
const common = require('../common');
4+
const assert = require('assert');
5+
const tls = require('tls');
6+
7+
common.expectWarning(
8+
'DeprecationWarning',
9+
'tls.createSecurePair() is deprecated. Please use tls.Socket instead.'
10+
);
11+
12+
assert.doesNotThrow(() => tls.createSecurePair());

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.