Showing with 557 additions and 65 deletions.
  1. +1 −0 AUTHORS
  2. +1 −1 README.md
  3. +2 −0 deps/debugger-agent/lib/_debugger_agent.js
  4. +3 −3 doc/api/path.markdown
  5. +100 −27 doc/api/tls.markdown
  6. +2 −0 lib/_debugger.js
  7. +2 −0 lib/_http_agent.js
  8. +2 −0 lib/_http_client.js
  9. +2 −0 lib/_http_common.js
  10. +2 −0 lib/_http_incoming.js
  11. +2 −0 lib/_http_outgoing.js
  12. +2 −0 lib/_http_server.js
  13. +2 −0 lib/_linklist.js
  14. +2 −0 lib/_stream_duplex.js
  15. +2 −0 lib/_stream_passthrough.js
  16. +5 −3 lib/_stream_readable.js
  17. +2 −0 lib/_stream_transform.js
  18. +2 −0 lib/_stream_writable.js
  19. +2 −0 lib/_tls_common.js
  20. +2 −0 lib/_tls_legacy.js
  21. +5 −3 lib/_tls_wrap.js
  22. +2 −0 lib/assert.js
  23. +2 −0 lib/buffer.js
  24. +2 −0 lib/child_process.js
  25. +2 −0 lib/cluster.js
  26. +2 −0 lib/console.js
  27. +2 −0 lib/constants.js
  28. +2 −0 lib/crypto.js
  29. +3 −1 lib/dgram.js
  30. +2 −0 lib/dns.js
  31. +2 −0 lib/domain.js
  32. +2 −0 lib/events.js
  33. +2 −0 lib/freelist.js
  34. +7 −1 lib/fs.js
  35. +2 −0 lib/http.js
  36. +2 −0 lib/https.js
  37. +2 −0 lib/module.js
  38. +18 −15 lib/net.js
  39. +2 −0 lib/os.js
  40. +2 −0 lib/path.js
  41. +2 −0 lib/querystring.js
  42. +2 −0 lib/readline.js
  43. +2 −0 lib/repl.js
  44. +2 −0 lib/smalloc.js
  45. +2 −0 lib/stream.js
  46. +2 −0 lib/string_decoder.js
  47. +2 −0 lib/sys.js
  48. +2 −0 lib/timers.js
  49. +8 −6 lib/tls.js
  50. +2 −0 lib/tty.js
  51. +4 −2 lib/url.js
  52. +2 −0 lib/util.js
  53. +2 −0 lib/vm.js
  54. +2 −0 lib/zlib.js
  55. +41 −0 src/node.cc
  56. +11 −0 src/node.h
  57. +3 −0 src/node.js
  58. +24 −0 src/node_crypto.cc
  59. +42 −0 src/node_crypto.h
  60. +2 −2 src/node_version.h
  61. +5 −0 test/simple/test-cluster-dgram-2.js
  62. +100 −0 test/simple/test-dgram-exclusive-implicit-bind.js
  63. +12 −0 test/simple/test-net-remote-address-port.js
  64. +66 −0 test/simple/test-tls-cipher-list.js
  65. +1 −0 test/simple/test-tls-dhe.js
  66. +1 −1 test/simple/test-tls-getcipher.js
  67. +8 −0 test/simple/test-url.js
@@ -202,6 +202,7 @@ Feross Aboukhadijeh
Florin-Cristian Gavrila
Forrest L Norvell
Francois Marier
Frank Cash
Fred K. Schott
Frederico Silva
Friedemann Altrock
@@ -194,7 +194,7 @@ Resources for Newcomers
- [searching the npm registry](http://npmjs.org/)
- [list of companies and projects using node](https://github.com/joyent/node/wiki/Projects,-Applications,-and-Companies-Using-Node)
- [node.js mailing list](http://groups.google.com/group/nodejs)
- irc chatroom, [#node.js on freenode.net](http://webchat.freenode.net?channels=node.js&uio=d4)
- [irc chatroom, #node.js on freenode.net](http://webchat.freenode.net?channels=node.js&uio=d4)
- [community](https://github.com/joyent/node/wiki/Community)
- [contributing](https://github.com/joyent/node/wiki/Contributing)
- [big list of all the helpful wiki pages](https://github.com/joyent/node/wiki/_pages)
@@ -1,3 +1,5 @@
'use strict';

var assert = require('assert');
var net = require('net');
var util = require('util');
@@ -200,7 +200,7 @@ An example on Windows:

process.env.PATH.split(path.delimiter)
// returns
['C:\Windows\system32', 'C:\Windows', 'C:\Program Files\nodejs\']
['C:\\Windows\\system32', 'C:\\Windows', 'C:\\Program Files\\nodejs\\']

## path.parse(pathString)

@@ -223,8 +223,8 @@ An example on Windows:
path.parse('C:\\path\\dir\\index.html')
// returns
{
root : "C:\",
dir : "C:\path\dir",
root : "C:\\",
dir : "C:\\path\\dir",
base : "index.html",
ext : ".html",
name : "index"
@@ -25,8 +25,10 @@ To create a self-signed certificate with the CSR, do this:

Alternatively you can send the CSR to a Certificate Authority for signing.

(TODO: docs on creating a CA, for now interested users should just look at
`test/fixtures/keys/Makefile` in the Node source code)
For Perfect Forward Secrecy, it is required to generate Diffie-Hellman
parameters:

openssl dhparam -outform PEM -out dhparam.pem 2048

To create .pfx or .p12, do this:

@@ -134,6 +136,81 @@ the character "E" appended to the traditional abbreviations):
Ephemeral methods may have some performance drawbacks, because key generation
is expensive.

## Modifying the Default Cipher Suite

Node.js is built with a default suite of enabled and disabled ciphers.
Currently, the default cipher suite is:

ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:
DHE-RSA-AES256-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:
HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA

This default can be overridden entirely using the `--cipher-list` command line
switch or `NODE_CIPHER_LIST` environment variable. For instance:

node --cipher-list=ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384

Setting the environment variable would have the same effect:

NODE_CIPHER_LIST=ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384

CAUTION: The default cipher suite has been carefully selected to reflect current
security best practices and risk mitigation. Changing the default cipher suite
can have a significant impact on the security of an application. The
`--cipher-list` and `NODE_CIPHER_LIST` options should only be used if
absolutely necessary.

### Using Legacy Default Cipher Suite ###

It is possible for the built-in default cipher suite to change from one release
of Node.js to another. For instance, v0.10.38 uses a different default than
v0.12.2. Such changes can cause issues with applications written to assume
certain specific defaults. To help buffer applications against such changes,
the `--enable-legacy-cipher-list` command line switch or `NODE_LEGACY_CIPHER_LIST`
environment variable can be set to specify a specific preset default:

# Use the v0.10.38 defaults
node --enable-legacy-cipher-list=v0.10.38
// or
NODE_LEGACY_CIPHER_LIST=v0.10.38

# Use the v0.12.2 defaults
node --enable-legacy-cipher-list=v0.12.2
// or
NODE_LEGACY_CIPHER_LIST=v0.12.2

Currently, the values supported for the `enable-legacy-cipher-list` switch and
`NODE_LEGACY_CIPHER_LIST` environment variable include:

v0.10.38 - To enable the default cipher suite used in v0.10.38

ECDHE-RSA-AES128-SHA256:AES128-GCM-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH

v0.10.39 - To enable the default cipher suite used in v0.10.39

ECDHE-RSA-AES128-SHA256:AES128-GCM-SHA256:HIGH:!RC4:!MD5:!aNULL:!EDH

v0.12.2 - To enable the default cipher suite used in v0.12.2

ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:AES128-GCM-SHA256:RC4:
HIGH:!MD5:!aNULL

v.0.12.3 - To enable the default cipher suite used in v0.12.3

ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:AES128-GCM-SHA256:HIGH:
!RC4:!MD5:!aNULL

These legacy cipher suites are also made available for use via the
`getLegacyCiphers()` method:

var tls = require('tls');
console.log(tls.getLegacyCiphers('v0.10.38'));

CAUTION: Changes to the default cipher suite are typically made in order to
strengthen the default security for applications running within Node.js.
Reverting back to the defaults used by older releases can weaken the security
of your applications. The legacy cipher suites should only be used if absolutely
necessary.

## tls.getCiphers()

@@ -144,6 +221,12 @@ Example:
var ciphers = tls.getCiphers();
console.log(ciphers); // ['AES128-SHA', 'AES256-SHA', ...]

## tls.getLegacyCiphers(version)

Returns the legacy default cipher suite for the specified Node.js release.

Example:
var cipher_suite = tls.getLegacyCiphers('v0.10.38');

## tls.createServer(options[, secureConnectionListener])

@@ -170,31 +253,20 @@ automatically set as a listener for the [secureConnection][] event. The
- `crl` : Either a string or list of strings of PEM encoded CRLs (Certificate
Revocation List)

- `ciphers`: A string describing the ciphers to use or exclude.

To mitigate [BEAST attacks] it is recommended that you use this option in
conjunction with the `honorCipherOrder` option described below to
prioritize the non-CBC cipher.

Defaults to
`ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:AES128-GCM-SHA256:RC4:HIGH:!MD5:!aNULL`.
Consult the [OpenSSL cipher list format documentation] for details
on the format.

`ECDHE-RSA-AES128-SHA256`, `DHE-RSA-AES128-SHA256` and
`AES128-GCM-SHA256` are TLS v1.2 ciphers and used when node.js is
linked against OpenSSL 1.0.1 or newer, such as the bundled version
of OpenSSL. Note that it is still possible for a TLS v1.2 client
to negotiate a weaker cipher unless `honorCipherOrder` is enabled.
- `ciphers`: A string describing the ciphers to use or exclude, separated by
`:`. The default cipher suite is:

`RC4` is used as a fallback for clients that speak on older version of
the TLS protocol. `RC4` has in recent years come under suspicion and
should be considered compromised for anything that is truly sensitive.
It is speculated that state-level actors possess the ability to break it.
ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:
DHE-RSA-AES256-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:
HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA

**NOTE**: Previous revisions of this section suggested `AES256-SHA` as an
acceptable cipher. Unfortunately, `AES256-SHA` is a CBC cipher and therefore
susceptible to [BEAST attacks]. Do *not* use it.
The default cipher suite prefers ECDHE and DHE ciphers for Perfect Forward
secrecy, while offering *some* backward compatibility. Old clients which
rely on insecure and deprecated RC4 or DES-based ciphers (like Internet
Explorer 6) aren't able to complete the handshake with the default
configuration. If you absolutely must support these clients, the
[TLS recommendations] may offer a compatible cipher suite. For more details
on the format, see the [OpenSSL cipher list format documentation].

- `ecdhCurve`: A string describing a named curve to use for ECDH key agreement
or false to disable ECDH.
@@ -212,7 +284,7 @@ automatically set as a listener for the [secureConnection][] event. The
times out.

- `honorCipherOrder` : When choosing a cipher, use the server's preferences
instead of the client preferences.
instead of the client preferences. Default: `true`.

Although, this option is disabled by default, it is *recommended* that you
use this option in conjunction with the `ciphers` option to mitigate
@@ -498,7 +570,7 @@ encrypted data, and one reads/writes cleartext data.
Generally the encrypted one is piped to/from an incoming encrypted data stream,
and the cleartext one is used as a replacement for the initial encrypted stream.

- `credentials`: A secure context object from tls.createSecureContext( ... )
- `context`: A secure context object from tls.createSecureContext( ... )

- `isServer`: A boolean indicating whether this tls connection should be
opened as a server or a client.
@@ -853,5 +925,6 @@ The numeric representation of the local port.
[ECDHE]: https://en.wikipedia.org/wiki/Elliptic_curve_Diffie%E2%80%93Hellman
[asn1.js]: http://npmjs.org/package/asn1.js
[OCSP request]: http://en.wikipedia.org/wiki/OCSP_stapling
[TLS recommendations]: https://wiki.mozilla.org/Security/Server_Side_TLS
[SSL_CTX_set_options]: https://www.openssl.org/docs/ssl/SSL_CTX_set_options.html
[CVE-2014-3566]: https://access.redhat.com/articles/1232123
@@ -19,6 +19,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';

var util = require('util'),
path = require('path'),
net = require('net'),
@@ -19,6 +19,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';

var net = require('net');
var util = require('util');
var EventEmitter = require('events').EventEmitter;
@@ -19,6 +19,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';

var util = require('util');
var net = require('net');
var url = require('url');
@@ -19,6 +19,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';

var FreeList = require('freelist').FreeList;
var HTTPParser = process.binding('http_parser').HTTPParser;

@@ -19,6 +19,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';

var util = require('util');
var Stream = require('stream');

@@ -19,6 +19,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';

var assert = require('assert').ok;
var Stream = require('stream');
var timers = require('timers');
@@ -19,6 +19,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';

var util = require('util');
var net = require('net');
var EventEmitter = require('events').EventEmitter;
@@ -19,6 +19,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';

function init(list) {
list._idleNext = list;
list._idlePrev = list;
@@ -19,6 +19,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';

// a duplex stream is just a stream that is both readable and writable.
// Since JS doesn't have multiple prototypal inheritance, this class
// prototypally inherits from Readable, and then parasitically from
@@ -19,6 +19,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';

// a passthrough stream.
// basically just the most minimal sort of Transform stream.
// Every written chunk gets output as-is.
@@ -19,6 +19,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';

module.exports = Readable;
Readable.ReadableState = ReadableState;

@@ -142,8 +144,7 @@ function readableAddChunk(stream, state, chunk, encoding, addToFront) {
stream.emit('error', er);
} else if (chunk === null) {
state.reading = false;
if (!state.ended)
onEofChunk(stream, state);
onEofChunk(stream, state);
} else if (state.objectMode || chunk && chunk.length > 0) {
if (state.ended && !addToFront) {
var e = new Error('stream.push() after EOF');
@@ -388,7 +389,8 @@ function chunkInvalid(state, chunk) {


function onEofChunk(stream, state) {
if (state.decoder && !state.ended) {
if (state.ended) return;
if (state.decoder) {
var chunk = state.decoder.end();
if (chunk && chunk.length) {
state.buffer.push(chunk);
@@ -19,6 +19,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';


// a transform stream is a readable/writable stream where you do
// something with the data. Sometimes it's called a "filter",
@@ -19,6 +19,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';

// A bit simpler than readable streams.
// Implement an async ._write(chunk, cb), and it'll handle all
// the drain event emission and buffering.
@@ -19,6 +19,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';

var util = require('util');
var constants = require('constants');
var tls = require('tls');
@@ -19,6 +19,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';

var assert = require('assert');
var events = require('events');
var stream = require('stream');
@@ -22,6 +22,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';

var assert = require('assert');
var crypto = require('crypto');
var net = require('net');
@@ -733,10 +735,10 @@ Server.prototype.setOptions = function(options) {
secureOptions |= constants.SSL_OP_CIPHER_SERVER_PREFERENCE;
}

if (options.honorCipherOrder)
this.honorCipherOrder = true;
if (options.honorCipherOrder !== undefined)
this.honorCipherOrder = !!options.honorCipherOrder;
else
this.honorCipherOrder = false;
this.honorCipherOrder = true;

this.secureOptions = secureOptions;