summaryrefslogtreecommitdiff
path: root/lib/tls.js
AgeCommit message (Collapse)Author
2018-12-20lib: switch to object spread where possibleRuben Bridgewater
Use the object spread notation instead of using Object.assign. It is not only easier to read it is also faster as of V8 6.8. PR-URL: https://github.com/nodejs/node/pull/25104 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2018-11-22tls: add min/max protocol version optionsSam Roberts
The existing secureProtocol option only allows setting the allowed protocol to a specific version, or setting it to "all supported versions". It also used obscure strings based on OpenSSL C API functions. Directly setting the min or max is easier to use and explain. PR-URL: https://github.com/nodejs/node/pull/24405 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org>
2018-10-23tls: throw if protocol too longAndre Jodat-Danbrani
The convertProtocols() function now throws a range error when the byte length of a protocol is too long to fit in a Buffer. Also added a test case in test/parallel/test-tls-basic-validations.js to cover this. PR-URL: https://github.com/nodejs/node/pull/23606 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2018-10-21src,lib: move `natives` and `constants` to `internalBinding()`Anna Henningsen
Refs: https://github.com/nodejs/node/issues/22160 PR-URL: https://github.com/nodejs/node/pull/23663 Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
2018-10-14tls: update try catch syntaxMatt Jiles
try catch syntax allows elimination of function arguments so removed unused err argument PR-URL: https://github.com/nodejs/node/pull/23484 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-10-08tls: update test & docs for ArrayBuffer/DataViewBeni von Cheni
In tls module, accept ArrayBuffer/DataView in place of isUint8Array in the source code & related test code in "test-tls-basic-validations.js", per the "tls" item in the checklist of the comment in #1826. PR-URL: https://github.com/nodejs/node/pull/23210 Refs: https://github.com/nodejs/node/issues/1826 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
2018-10-04bootstrapper: move internalBinding to NativeModuleGus Caplan
internalBinding is used so often that it should just automatically be available for usage in internals. PR-URL: https://github.com/nodejs/node/pull/23025 Refs: https://github.com/nodejs/node/commit/2a9eb31 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-08-30dns: make process.binding('cares_wrap') internalcjihrig
PR-URL: https://github.com/nodejs/node/pull/22474 Refs: https://github.com/nodejs/node/issues/22160 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-08-24crypto: move process.binding('crypto') to internalDaniel Bevenius
This commit makes the crypto builtin an internal builtin, and changes usage of the builtin from using process.binding('crypto') to use internalBinding instead. Refs: https://github.com/nodejs/node/issues/22160 PR-URL: https://github.com/nodejs/node/pull/22426 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-08-12tls: remove SLAB_BUFFER_SIZEAnatoli Papirovski
This constant has not been in use for many years now and the test alongside it is invalid, as well as flaky. PR-URL: https://github.com/nodejs/node/pull/21199 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-07-18tls: name anonymous function in tls.jsKevin Lacabane
Refs: https://github.com/nodejs/node/issues/8913 PR-URL: https://github.com/nodejs/node/pull/21754 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Jon Moss <me@jonathanmoss.me>
2018-06-01doc: fix inconsistent documentation (host vs hostname)Davis Okoth
Update reference to read `hostname` instead of `host` for consistency. Also update function signature to use `hostname` rather than `host` PR-URL: https://github.com/nodejs/node/pull/20933 Refs: https://github.com/nodejs/node/issues/20892 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2018-05-17tls: move convertNPNProtocols to End-of-LifeJames M Snell
This was deprecated in 10.0.0 because NPN support was removed. It does not make sense to keep this around longer than 10.x PR-URL: https://github.com/nodejs/node/pull/20736 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
2018-04-29http,https,tls: switch to WHATWG URL parserHackzzila
This switches the url parser from `url.parse()` to the WHATWG URL parser while keeping `url.parse()` as fallback. Also add tests for invalid url deprecations and correct hostname checks. PR-URL: https://github.com/nodejs/node/pull/20270 Fixes: https://github.com/nodejs/node/issues/19468 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-04-19lib: remove duplicate require calls in tls.jsDaniel Bevenius
This commit removes the duplicate require calls of the _tls_common and _tls_wrap modules. The motivation for this being that even though the modules are cached the additional calls are unnecessary. PR-URL: https://github.com/nodejs/node/pull/20099 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-04-19lib: use object destructuring tls.jsDaniel Bevenius
This commit updates canonicalizeIP and Buffer to use object destructuring which is done for other functions in lib/tls.js PR-URL: https://github.com/nodejs/node/pull/20070 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-03-27tls: runtime-deprecate tls.convertNPNProtocols()Ben Noordhuis
Fixes: https://github.com/nodejs/node/issues/14602 PR-URL: https://github.com/nodejs/node/pull/19403 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2018-03-05lib: port errors to new systemMichaël Zasso
This is a first batch of updates that touches non-underscored modules in lib. PR-URL: https://github.com/nodejs/node/pull/19034 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2018-01-14tls: make deprecated tls.createSecurePair() use public APIAnna Henningsen
Make the deprecated `tls.createSecurePair()` method use other public APIs only (`TLSSocket` in particular). Since `tls.createSecurePair()` has been runtime-deprecated only since Node 8, it probably isn’t quite time to remove it yet, but this patch removes almost all of the code complexity that is retained by it. The API, as it is documented, is retained. However, it is very likely that some users have come to rely on parts of undocumented API of the `SecurePair` class, especially since some of the existing tests checked for those. Therefore, this should definitely be considered a breaking change. PR-URL: https://github.com/nodejs/node/pull/17882 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
2017-12-01doc: document tls.checkServerIdentityHannes Magnusson
The funciton was added in eb2ca104628e415fc73c330cdd76fca77bf5ba97 PR-URL: https://github.com/nodejs/node/pull/17203 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2017-11-29tls: set ecdhCurve default to 'auto'Hativ
For best out-of-the-box compatibility there should not be one default `ecdhCurve` for the tls client, OpenSSL should choose them automatically. See https://wiki.openssl.org/index.php/Manual:SSL_CTX_set1_curves(3) PR-URL: https://github.com/nodejs/node/pull/16853 Refs: https://github.com/nodejs/node/issues/16196 Refs: https://github.com/nodejs/node/issues/1495 Refs: https://github.com/nodejs/node/pull/15206 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2017-11-02http, tls: better support for IPv6 addressesMattias Holmlund
- Properly handle IPv6 in Host header when setting servername. - When comparing IP addresses against addresses in the subjectAltName field of a certificate, format the address correctly before doing the string comparison. PR-URL: https://github.com/nodejs/node/pull/14772 Fixes: https://github.com/nodejs/node/issues/14736 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-10-01lib: faster type checks for some typesTimothy Gu
PR-URL: https://github.com/nodejs/node/pull/15663 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Benedikt Meurer <benedikt.meurer@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-09-24tls,doc: fix unallocated deprecation codeJames M Snell
Deprecation was landed using `DEP00XX` instead of a properly allocated deprecation code. PR-URL: https://github.com/nodejs/node/pull/15534 Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2017-09-13tls: deprecate parseCertString & move to internalXadillaX
`tls.parseCertString()` exposed by accident. Now move this function to `internal/tls` and mark the original one as deprecated. PR-URL: https://github.com/nodejs/node/pull/14249 Refs: https://github.com/nodejs/node/issues/14193 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2017-08-30tls: fix object prototype type confusionBen Noordhuis
Use `Object.create(null)` for dictionary objects so that keys from certificate strings or the authorityInfoAccess field cannot conflict with Object.prototype properties. PR-URL: https://github.com/nodejs/node/pull/14447 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2017-07-18tls: migrate tls.js to use internal/errors.jsMichael Dawson
Migrate tls.js to use internal/errors.js as per https://github.com/nodejs/node/issues/11273 PR-URL: https://github.com/nodejs/node/pull/13994 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2017-07-07lib: remove excess indentationRich Trott
In anticipation of stricter linting for indentation, remove instances of extra indentation that will be flagged by the new rules. PR-URL: https://github.com/nodejs/node/pull/14090 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2017-06-23benchmark,lib,test: use braces for multiline blockRich Trott
For if/else and loops where the bodies span more than one line, use curly braces. PR-URL: https://github.com/nodejs/node/pull/13828 Ref: https://github.com/nodejs/node/pull/13623#discussion_r123048602 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-06-19lib: fix typosRuben Bridgewater
PR-URL: https://github.com/nodejs/node/pull/13741 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
2017-03-27tls: support Uint8Arrays for protocol list buffersAnna Henningsen
PR-URL: https://github.com/nodejs/node/pull/11984 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-03-10meta: restore original copyright headerJames M Snell
A prior io.js era commit inappropriately removed the original copyright statements from the source. This restores those in any files still remaining from that edit. Ref: https://github.com/nodejs/TSC/issues/174 Ref: https://github.com/nodejs/node/pull/10599 PR-URL: https://github.com/nodejs/node/pull/10155 Note: This PR was required, reviewed-by and approved by the Node.js Foundation Legal Committee and the TSC. There is no `Approved-By:` meta data.
2017-03-06tls: runtime deprecation for tls.createSecurePair()James M Snell
Upgrade the deprecation for _tls_legacy (`tls.createSecurePair()`) to a runtime deprecation. PR-URL: https://github.com/nodejs/node/pull/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>
2017-01-18lib: remove unnecessary parameter for assertCrypto()Jackson Tian
The `exports` parameter is unnecessary. PR-URL: https://github.com/nodejs/node/pull/10834 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sam Roberts <sam@strongloop.com>
2017-01-16crypto,tls: fix mutability of return valuesRich Trott
If you alter the array returned by `tls.getCiphers()`, `crypto.getCiphers()`, `crypto.getHashes()`, or `crypto.getCurves()`, it will alter subsequent return values from those functions. ```js 'use strict'; const crypto = require('crypto'); var hashes = crypto.getHashes(); hashes.splice(0, hashes.length); hashes.push('some-arbitrary-value'); console.log(crypto.getHashes()); // "['some-arbitrary-value']" ``` This is surprising. Change functions to return copy of array instead. PR-URL: https://github.com/nodejs/node/pull/10795 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
2016-10-04lib: remove let from for loopsMyles Borins
This is a known de-opt. It may not be 100% necessary in all cases but it seems like a decent enough idea to avoid it. PR-URL: https://github.com/nodejs/node/pull/8873 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com> Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
2016-09-28lib: make tls.checkServerIdentity() more strictBen Noordhuis
PR-URL: https://github.com/nodejs/node-private/pull/75 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2016-09-18tls: add 'new' keyword for Array constructor callMike Ralphson
PR-URL: https://github.com/nodejs/node/pull/8514 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2016-08-17tls: copy the Buffer object before usingSakthipriyan Vairamani
`convertNPNProtocols` and `convertALPNProtocols' uses the `protocols` buffer object as it is, and if it is modified outside of core, it might have an impact. This patch makes a copy of the buffer object, before using it. PR-URL: https://github.com/nodejs/node/pull/8055 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
2016-06-21tls: avoid calling Buffer.byteLength multiple timesJames M Snell
There's no reason to be calling Buffer.byteLength() twice. Small perf improvement Run 1: tls/convertprotocols.js n=1 v6.2.1 = 11852, new = 12204 ...... -2.89% tls/convertprotocols.js n=50000 v6.2.1 = 515660, new = 570610 ..... -9.63% Run 2: tls/convertprotocols.js n=1 v6.2.1 = 11729, new = 12045 ...... -2.62% tls/convertprotocols.js n=50000 v6.2.1 = 512080, new = 637730 ..... -19.70% PR-URL: https://github.com/nodejs/node/pull/7236 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
2016-06-21crypto,tls: perf improvements for crypto and tls getCiphersJames M Snell
Improve performance of crypto.getCiphers, getHashes, getCurves and tls.getCiphers by consolidating filterDuplicates logic, adding caching of output, and streamlining filterDuplicates implementation. Benchmarks: crypto.getCiphers n=1 v6.2.1 = 2559.3, new = 15890 ...... -83.89% crypto.getCiphers n=5000 v6.2.1 = 3516.3, new = 24203000 ... -99.99% tls.getCiphers n=1 v6.2.1 = 3405.3, new = 14877 ...... -77.11% tls.getCiphers n=5000 v6.2.1 = 6074.4, new = 24202000 ... -99.97% PR-URL: https://github.com/nodejs/node/pull/7225 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
2016-05-17src: refactor require('constants')James M Snell
The require('constants') module is currently undocumented and mashes together unrelated constants. This refactors the require('constants') in favor of distinct os.constants, fs.constants, and crypto.constants that are specific to the modules for which they are relevant. The next step is to document those within the specific modules. PR-URL: https://github.com/nodejs/node/pull/6534 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Robert Lindstaedt <robert.lindstaedt@gmail.com>
2016-05-11benchmark,test,lib: remove extra spacesRich Trott
In preparation for stricter linting, remove extra spaces. PR-URL: https://github.com/nodejs/node/pull/6645 Reviewed-By: Michaël Zasso <mic.besace@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Roman Reiss <me@silverwind.io>
2016-03-23crypto: fail early when loading crypto without opensslJames M Snell
Fail early in require('crypto'), require('tls'), require('https'), etc when crypto is not available (rather than depending on an internal try/catch). Add documentation for detecting when crypto is not available. PR-URL: https://github.com/nodejs/node/pull/5611 Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-03-23lib: refactor code with startsWith/endsWithJackson Tian
reduce using RegExp for string test. This pull reuqest replaces various usages of regular expressions in favor of the ES2015 startsWith and endsWith methods. PR-URL: https://github.com/nodejs/node/pull/5753 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
2016-03-16buffer: add .from(), .alloc() and .allocUnsafe()James M Snell
Several changes: * Soft-Deprecate Buffer() constructors * Add `Buffer.from()`, `Buffer.alloc()`, and `Buffer.allocUnsafe()` * Add `--zero-fill-buffers` command line option * Add byteOffset and length to `new Buffer(arrayBuffer)` constructor * buffer.fill('') previously had no effect, now zero-fills * Update the docs PR-URL: https://github.com/nodejs/node/pull/4682 Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
2016-01-16lib,test: remove extra semicolonsMichaël Zasso
PR-URL: https://github.com/nodejs/node/pull/2205 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
2016-01-13lib: fix style issues after eslint updateMichaël Zasso
With an indentation style of two spaces, it is not possible to indent multiline variable declarations by four spaces. Instead, the var keyword is used on every new line. Use const instead of var where applicable for changed lines. PR-URL: https://github.com/nodejs/io.js/pull/2286 Reviewed-By: Roman Reiss <me@silverwind.io>
2015-10-28tls: remove util and calls to util.formatMyles Borins
Currently util.format is being used for string templating in tls. By replacing all of the instances of util.format with backtick string we can remove the need to require util in tls all together. PR-URL: https://github.com/nodejs/node/pull/3456 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-10-27tls, crypto: add ALPN SupportShigeki Ohtsu
ALPN is added to tls according to RFC7301, which supersedes NPN. When the server receives both NPN and ALPN extensions from the client, ALPN takes precedence over NPN and the server does not send NPN extension to the client. alpnProtocol in TLSSocket always returns false when no selected protocol exists by ALPN. In https server, http/1.1 token is always set when no options.ALPNProtocols exists. PR-URL: https://github.com/nodejs/node/pull/2564 Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>