0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
Commit Graph

205 Commits

Author SHA1 Message Date
Fedor Indutny
9b6b05556f net: unref timer in parent sockets
`TLSSocket` wraps the original `net.Socket`, but writes/reads to/from
`TLSSocket` do not touch the timers of original `net.Socket`.

Introduce `socket._parent` property, and iterate through all parents
to unref timers and prevent timeout event on original `net.Socket`.

Fix: https://github.com/joyent/node/issues/9242
PR-URL: https://github.com/iojs/io.js/pull/891
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-02-19 18:44:10 +01:00
Roman Reiss
77f35861d0 tls: more secure defaults
This updates the default cipher suite to an more secure list, which
prefers strong ciphers with Forward Secrecy. Additionally, it enables
`honorCipherOrder` by default.

Noteable effect of this change is that the insecure RC4 ciphers are
disabled and that Chrome negotiates a more secure ECDHE cipher.

Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
PR-URL: https://github.com/iojs/io.js/pull/826
2015-02-16 12:33:12 +01:00
cjihrig
6ac8bdc0ab lib: reduce util.is*() usage
Many of the util.is*() methods used to check data types
simply compare against a single value or the result of
typeof. This commit replaces calls to these methods with
equivalent checks. This commit does not touch calls to the
more complex methods (isRegExp(), isDate(), etc.).

Fixes: https://github.com/iojs/io.js/issues/607
PR-URL: https://github.com/iojs/io.js/pull/647
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-31 23:47:29 -05:00
cjihrig
804e7aa9ab lib: use const to define constants
This commit replaces a number of var statements throughout
the lib code with const statements.

PR-URL: https://github.com/iojs/io.js/pull/541
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-21 16:21:31 -05:00
isaacs
3e1b1dd4a9 Remove excessive copyright/license boilerplate
The copyright and license notice is already in the LICENSE file.  There
is no justifiable reason to also require that it be included in every
file, since the individual files are not individually distributed except
as part of the entire package.
2015-01-12 15:30:28 -08:00
Ben Noordhuis
21130c7d6f lib: turn on strict mode
Turn on strict mode for the files in the lib/ directory.  It helps
catch bugs and can have a positive effect on performance.

PR-URL: https://github.com/node-forward/node/pull/64
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-11-22 17:23:30 +01:00
Fedor Indutny
963f5e8a88 tls: do not hang without newSession handler
When listening for client hello parser events (like OCSP requests), do
not hang if `newSession` event handler is not present.

fix joyent/node#8660
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
PR-URL: https://github.com/node-forward/node/pull/47
2014-11-20 18:14:57 +03:00
Trevor Livingston
bf5e2f246e tls: checkServerIdentity option
Allow overriding `checkServerIdentity` function, when connecting to a
TLS server.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-09-09 17:15:50 +01:00
Shigeki Ohtsu
0dfedb7127 tls, crypto: add DHE support
In case of an invalid DH parameter file, it is sliently discarded. To
use auto DH parameter in a server and DHE key length check in a
client, we need to wait for the next release of OpenSSL-1.0.2.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-08-29 00:36:48 +04:00
Jackson Tian
931cbc175f lib: don't use emitter.listeners(type).length
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-08-12 15:57:13 -07:00
Jackson Tian
bbb2dccd1b tls: throw an error, not string
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-08-01 18:10:15 +04:00
Brian White
857975d5e7 tls_wrap: remove unused variable
Closes #7957.
2014-07-16 21:46:26 -07:00
Fedor Indutny
e345253562 tls: better error reporting at cert validation
fix #7417

Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-07-03 00:41:39 +04:00
Fedor Indutny
c147e81091
crypto: add honorCipherOrder argument
Add `honorCipherOrder` argument to `crypto.createCredentials`.

fix #7249
2014-06-25 14:47:59 +04:00
Fedor Indutny
afaff70a9b src: lint after OCSP commits 2014-04-18 02:24:48 +04:00
Fedor Indutny
345c40b661 tls: getPeerCertificate(detailed)
Add `raw` property to certificate, add mode to output full certificate
chain.
2014-04-18 02:21:16 +04:00
Fedor Indutny
b3ef289ffb tls: support OCSP on client and server 2014-04-18 02:21:16 +04:00
Fedor Indutny
77d1f4a91f tls: set _connecting before starting the flow
When creating a TLSSocket instance based on the existing connecting
socket, `_connecting` property is copied after the initialization of
`net.Socket`. However, since `net.Socket` constructor will call
`.read(0)` if the `readable` is true - error may happen at this code
chunk in net.js:

    Socket.prototype._read = function(n) {
      debug('_read');

      if (this._connecting || !this._handle) {
        debug('_read wait for connection');
        this.once('connect', this._read.bind(this, n));
    ...

Leading to a test failures on windows:

 - test/simple/test-tls-connect-given-socket.js

Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-04-17 14:27:09 +04:00
Fedor Indutny
5d2aef17ee
crypto: move createCredentials to tls
Move `createCredentials` to `tls` module and rename it to
`createSecureContext`. Make it use default values from `tls` module:
`DEFAULT_CIPHERS` and `DEFAULT_ECDH_CURVE`.

fix #7249
2014-03-29 12:01:43 +04:00
Fedor Indutny
d24946b1b4 tls: do not call SNICallback unless present
When asynchronously parsing ClientHello for session resumption -
SNICallback may not be set. Check if it is present before invoking
it.

fix #7010
2014-03-27 23:26:52 +04:00
Fedor Indutny
ef096f8d8f tls: force readable/writable to true
These are an old and deprecated properties that was used by previous
stream implementation, and are still in use in some user-land modules.

Prior to this commit, they were read from the underlying socket, which
may be non-readable/non-writable while connecting or while staying
uninitialized.

Force set them to `true`, just to make sure that there will be no
inconsistency.

fix #7152
2014-03-27 23:25:30 +04:00
Fedor Indutny
78d245f5b2 Merge remote-tracking branch 'origin/v0.10'
Conflicts:
	configure
	lib/_stream_readable.js
	lib/http.js
	src/node_dtrace.cc
2014-03-02 23:54:19 +04:00
Fedor Indutny
75ea11fc08 tls: introduce asynchronous newSession
fix #7105
2014-02-18 01:07:09 +04:00
Fedor Indutny
e2a1d9a9ac stream: use errorEmitted from _writableState 2014-02-10 11:06:03 -08:00
Fedor Indutny
528a3ce3ed tls: more session configuration options, methods
Introduce `ticketKeys` server option, `session` client option,
`getSession()` and `getTLSTicket()` methods.

fix #7032
2014-02-05 23:28:34 +04:00
Jacob Hoffman-Andrews
f4c8020d10 crypto: honor default ciphers in client mode
Right now no default ciphers are use in, e.g. https.get, meaning that
weak export ciphers like TLS_RSA_EXPORT_WITH_DES40_CBC_SHA are
accepted.

To reproduce:

node -e "require('https').get({hostname: 'www.howsmyssl.com', \
  path: '/a/check'}, function(res) {res.on('data', \
  function(d) {process.stdout.write(d)})})"
2014-01-28 03:28:09 +04:00
Fedor Indutny
d019eac5b5 tls: emit clientError on early socket close
fix #6903
2014-01-24 22:09:17 +04:00
Fedor Indutny
c79c304ead tls: process accumulated input
When creating TLSSocket on top of the regular socket that already
contains some received data, `_tls_wrap.js` should try to write all that
data to the internal `SSL*` instance.

fix #6940
2014-01-23 20:39:32 +04:00
Fedor Indutny
7f9b01509f lib: introduce .setMaxSendFragment(size)
fix #6889
2014-01-20 20:39:57 +04:00
Ben Noordhuis
db5abd726f tls: make cert/pfx optional in tls.createServer()
Not all ciphers require the presence of a certificate.  Remove the
check in lib/_tls_wrap.js.

Fixes #6887.
2014-01-17 18:55:33 +00:00
Ben Noordhuis
262a752c29 tls: show human-readable error messages
Before this commit, verification exceptions had err.message set to the
OpenSSL error code (e.g. 'UNABLE_TO_VERIFY_LEAF_SIGNATURE').

This commit moves the error code to err.code and replaces err.message
with a human-readable error.  Example:

    // before
    {
      message: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'
    }

    // after
    {
      code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE',
      message: 'unable to verify the first certificate'
    }

UNABLE_TO_VERIFY_LEAF_SIGNATURE is a good example of why you want this:
the error code suggests that it's the last certificate that fails to
validate while it's actually the first certificate in the chain.

Going by the number of mailing list posts and StackOverflow questions,
it's a source of confusion to many people.
2014-01-17 18:51:25 +00:00
Fedor Indutny
7c3643b767 tls: reintroduce socket.encrypted
Just a property that is always `true` for TLS sockets.

fix #6735
2013-12-21 01:03:05 +04:00
Fedor Indutny
f572b91c3e tls: fix handling of asterisk in SNI context
Wildcard server names should not match subdomains.

Quote from RFC2818:

   ...Names may contain the wildcard
   character * which is considered to match any single domain name
   component or component fragment. E.g., *.a.com matches foo.a.com but
   not bar.foo.a.com. f*.com matches foo.com but not bar.com.

fix #6610
2013-12-05 19:45:19 -08:00
Fedor Indutny
a6ddfe20d2 tls: more accurate wrapping of connecting socket
When socket, passed in `tls.connect()` `options` argument is not yet
connected to the server, `_handle` gets assigned to a `net.Socket`,
instead of `TLSSocket`.

When socket is connecting to the remote server (i.e. not yet connected,
but already past dns resolve phase), derive `_connecting` property from
it, because otherwise `afterConnect()` will throw an assertion.

fix #6443
2013-11-05 18:14:28 +04:00
Erik Dubbelboer
bb909ad642 tls: add ECDH ciphers support
Switch test fixtures to 1024 bit keys.
2013-10-30 08:34:47 +01:00
Fedor Indutny
ba7c9ce964 tls: do not default to 'localhost' servername 2013-10-31 01:57:20 +04:00
Fedor Indutny
5977cba985 tls: reuse hostname from underlying net.Socket
When `tls.connect()` is called with `socket` option, it should try to
reuse hostname previously passed to `net.connect()` and only after that
fall back to `'localhost'`.

fix #6409
2013-10-31 01:57:17 +04:00
Trevor Norris
25dce6d62d lint: fix a few semicolons 2013-09-24 14:35:30 -07:00
Fedor Indutny
42acbf809b tls: wrap tls inside tls using legacy API
Allow wrapping TLSSocket inside another TLSSocket, emulate it using
SecurePair in legacy APIs.

fix #6204
2013-09-24 20:46:59 +04:00
Fedor Indutny
af76b08666 tls: socket.renegotiate(options, callback)
This utility function allows renegotiaion of secure connection after
establishing it.

fix #2496
2013-09-05 18:10:31 +04:00
isaacs
1df77a7438 lib: Add missing copyright notices 2013-08-27 07:27:39 -07:00
Matthew Aynalem
c171c490f2 fixes #6031 spelling errors
explictly => explicitly
accesss => access
througput => throughput
epxression => expression
communiction => communication
becuase => because
repersent => represent
condonitions => conditions
decompresion => decompression
intentially => intentionally
eventes => events
listning => listening
resicved => received
becuase => because
fundimental => fundamental
colapse => collapse
privlages => privileges
sufficently => sufficiently
hapepns => happens
expliclitly => explicitly
thier => their
shold => should
2013-08-19 16:42:16 -07:00
Brian White
6d842897c5 lib: remove unused variables and functions 2013-08-15 17:19:17 -07:00
Fedor Indutny
c50750e1fd tls: handle errors on socket before releasing it
Fix sudden uncatchable ECONNRESETs, when using https server.
2013-08-14 21:10:32 +04:00
Fedor Indutny
166c405b33 tls: fix lazy initialization of clienthello parser
`server.SNICallback` was initialized with `SNICallback.bind(this)`, and
therefore check `this.SNICallback === SNICallback` was always false, and
`_tls_wrap.js` always thought that it was a custom callback instead of
default one. Which in turn was causing clienthello parser to be enabled
regardless of presence of SNI contexts.
2013-08-07 00:57:32 +04:00
Fedor Indutny
048e0e77e0 tls: asynchronous SNICallback
Make ClientHelloParser handle SNI extension, and extend `_tls_wrap.js`
to support loading SNI Context from both hello, and resumed session.

fix #5967
2013-08-06 16:13:01 +04:00
Fedor Indutny
ea7b817266 tls: fix handling of SNICallback server option
It shouldn't ignore it!

There're two possibile cases, which should be handled properly:

1. Having a default `SNICallback` which is using contexts, added with
  `server.addContext(...)` routine
2. Having a custom `SNICallback`.

In first case we may want to opt-out setting `.onsniselect` method (and
thus save some CPU time), if there're no contexts added. But, if custom
`SNICallback` is used, `.onsniselect` should always be set, because
server contexts don't affect it.
2013-08-04 14:11:28 +04:00
isaacs
22c68fdc1d src: Replace macros with util functions 2013-08-01 15:08:01 -07:00
Fedor Indutny
dda22a520b tls_wrap: parse tls session ticket extension
And, if present and non-empty, don't invoke `resumeSession` callback.

fix #5872
2013-08-01 16:06:45 +04:00
Fedor Indutny
d62c2d975a tls: share tls tickets key between cluster workers
fix #5871
2013-07-25 01:16:00 +04:00
Ben Noordhuis
0330bdf519 lib: macro-ify type checks
Increases the grep factor. Makes it easier to harmonize type checks
across the code base.
2013-07-24 21:49:35 +02:00
Fedor Indutny
07fbb43d78 tls: export TLSSocket 2013-07-03 16:15:31 +04:00
Fedor Indutny
212e9cd8c9 tls: session API returns 2013-06-17 14:00:26 +02:00
Fedor Indutny
dc50f27d52 tls: share socket._hadError with http_client 2013-06-16 09:30:15 +02:00
Fedor Indutny
af80e7bc6e tls: introduce TLSSocket based on tls_wrap binding
Split `tls.js` into `_tls_legacy.js`, containing legacy
`createSecurePair` API, and `_tls_wrap.js` containing new code based on
`tls_wrap` binding.

Remove tests that are no longer useful/valid.
2013-06-16 09:30:15 +02:00