summaryrefslogtreecommitdiff
path: root/src/tls_wrap.h
Commit message (Collapse)AuthorAgeFilesLines
* src: remove nonexistent method from header fileAnna Henningsen2018-02-121-1/+0
| | | | | | PR-URL: https://github.com/nodejs/node/pull/17748 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
* net: fix timeouts during long writesAnatoli Papirovski2018-01-021-0/+4
| | | | | | | | | | | | | | | | | | Add updateWriteQueueSize which updates and returns queue size (net & tls). Make _onTimeout check whether an active write is ongoing and if so, call _unrefTimer rather than emitting a timeout event. Add http & https test that checks whether long-lasting (but active) writes timeout or can finish writing as expected. Backport-PR-URL: https://github.com/nodejs/node/pull/16420 PR-URL: https://github.com/nodejs/node/pull/15791 Fixes: https://github.com/nodejs/node/issues/15082 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
* tls: properly track writeQueueSize during writesAnatoli Papirovski2018-01-021-0/+1
| | | | | | | | | | | | | | | Make writeQueueSize represent the actual size of the write queue within the TLS socket. Add tls test to confirm that bufferSize works as expected. Backport-PR-URL: https://github.com/nodejs/node/pull/16420 PR-URL: https://github.com/nodejs/node/pull/15791 Fixes: https://github.com/nodejs/node/issues/15005 Refs: https://github.com/nodejs/node/pull/15006 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
* src: replace manual memory mgmt with std::stringBen Noordhuis2017-10-251-3/+4
| | | | | | | | | | PR-URL: https://github.com/nodejs/node/pull/15782 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* src: move crypto_bio/clienthello to crypto nsDaniel Bevenius2017-08-151-2/+2
| | | | | | | | | | | | | Currently, node_crypto_bio and node_crypto_clienthello are not in the crypto namespace but simply in the node namespace. Not sure if this was intentional or not, but I think it would make sense to move them to be consistent. PR-URL: https://github.com/nodejs/node/pull/13957 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
* Partial revert "tls: keep track of stream that is closed"Trevor Norris2017-04-181-1/+0
| | | | | | | | | | | This partually reverts commit 4cdb0e89d8daf7e1371c3b8d3f057940aa327d4a. A nullptr check in TSLWrap::IsAlive() and the added test were left. PR-URL: https://github.com/nodejs/node/pull/11947 Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
* stream_base,tls_wrap: notify on destructTrevor Norris2017-04-181-0/+3
| | | | | | | | | | | | | | | | | | | | | The TLSWrap constructor is passed a StreamBase* which it stores as TLSWrap::stream_, and is used to receive/send data along the pipeline (e.g. tls -> tcp). Problem is the lifetime of the instance that stream_ points to is independent of the lifetime of the TLSWrap instance. So it's possible for stream_ to be delete'd while the TLSWrap instance is still alive, allowing potential access to a then invalid pointer. Fix by having the StreamBase destructor null out TLSWrap::stream_; allowing all TLSWrap methods that rely on stream_ to do a check to see if it's available. While the test provided is fixed by this commit, it was also previously fixed by 478fabf. Regardless, leave the test in for better testing. PR-URL: https://github.com/nodejs/node/pull/11947 Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
* tls: keep track of stream that is closedjBarz2017-04-181-0/+1
| | | | | | | | | | | | | TLSWrap object keeps a pointer reference to the underlying TCPWrap object. This TCPWrap object could be closed and deleted by the event-loop which leaves us with a dangling pointer. So the TLSWrap object needs to track the "close" event on the TCPWrap object. PR-URL: https://github.com/nodejs/node/pull/11776 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
* src: remove unused data member write_queue_size_Ben Noordhuis2016-07-051-1/+0
| | | | | | | | | | Remove TLSWrap::write_queue_size_, it's not used anywhere. PR-URL: https://github.com/nodejs/node/pull/7374 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
* src: fix runtime/indentation_namespace warningsBen Noordhuis2016-07-051-1/+1
| | | | | PR-URL: https://github.com/nodejs/node/pull/7462 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
* src: add include guards to internal headersBen Noordhuis2016-06-021-0/+4
| | | | | | | | | | | For consistency with the newly added src/base64.h header, check that NODE_WANT_INTERNALS is defined and set in internal headers. PR-URL: https://github.com/nodejs/node/pull/6948 Refs: https://github.com/nodejs/node/pull/6910 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
* tls_wrap: reach error reporting for UV_EPROTOFedor Indutny2016-01-271-1/+1
| | | | | | | | | | | Do not swallow error details when reporting UV_EPROTO asynchronously, and when creating artificial errors. Fix: #3692 PR-URL: https://github.com/nodejs/node/pull/4885 Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* tls_wrap: inherit from the `AsyncWrap` firstFedor Indutny2015-12-141-3/+3
| | | | | | | | | | | | | `WrapperInfo` casts pointer in JS object's internal field to `AsyncWrap`. This approach fails miserably for `TLSWrap` because it was inhereted from the `StreamBase` first, creating different kind of `vtable` for the whole class. Reorder parent classes to put `AsyncWrap` first. Fix: https://github.com/nodejs/node/issues/4250 PR-URL: https://github.com/nodejs/node/pull/4268 Reviewed-By: James M Snell <jasnell@gmail.com>
* src: replace usage of v8::Handle with v8::LocalMichaƫl Zasso2015-09-061-3/+3
| | | | | | | v8::Handle is deprecated: https://codereview.chromium.org/1224623004 PR-URL: https://github.com/nodejs/io.js/pull/2202 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* tls: fix throughput issues after incorrect mergeFedor Indutny2015-08-171-1/+1
| | | | | | | | | | | 1e066e4a was done incorrectly and has overwritten an important change in: c17449df. Using bigger output buffer increases performance in 3-4 times. PR-URL: https://github.com/nodejs/node/pull/2381 Fix: https://github.com/joyent/node/issues/25803 Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
* async-wrap: add provider id and object info cbTrevor Norris2015-06-171-0/+2
| | | | | | | | | | | | | | | | | | | Re-add the wrapper class id to AsyncWrap instances so they can be tracked directly in a heapdump. Previously the class id was given without setting the heap dump wrapper class info provider. Causing a segfault when a heapdump was taken. This has been added, and the label_ set to the given provider name so each instance can be identified. The id will not be set of the passed object has no internal field count. As the class pointer cannot be retrieved from the object. In order to properly report the allocated size of each class, the new pure virtual method self_size() has been introduces. PR-URL: https://github.com/nodejs/io.js/pull/1896 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* tls: use `SSL_set_cert_cb` for async SNI/OCSPFedor Indutny2015-05-011-5/+1
| | | | | | | | | | | | | | | | | Do not enable ClientHello parser for async SNI/OCSP. Use new OpenSSL-1.0.2's API `SSL_set_cert_cb` to pause the handshake process and load the cert/OCSP response asynchronously. Hopefuly this will make whole async SNI/OCSP process much faster and will eventually let us remove the ClientHello parser itself (which is currently used only for async session, see #1462 for the discussion of removing it). NOTE: Ported our code to `SSL_CTX_add1_chain_cert` to use `SSL_CTX_get0_chain_certs` in `CertCbDone`. Test provided for this feature. Fix: https://github.com/iojs/io.js/issues/1423 PR-URL: https://github.com/iojs/io.js/pull/1464 Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
* tls: destroy SSL once it is out of useFedor Indutny2015-04-301-0/+1
| | | | | | | | | Do not keep SSL structure in memory once socket is closed. This should lower the memory usage in many cases. Fix: https://github.com/iojs/io.js/issues/1522 PR-URL: https://github.com/iojs/io.js/pull/1529 Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
* tls_wrap: do not hold persistent ref to parentFedor Indutny2015-03-061-4/+1
| | | | | | | Hold non-persistent reference in JS, rather than in C++ to avoid cycles. PR-URL: https://github.com/iojs/io.js/pull/1078 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* streams: introduce StreamWrap and JSStreamFedor Indutny2015-02-241-6/+5
| | | | | | | | | | Introduce a way to wrap plain-js `stream.Duplex` streams into C++ StreamBase's child class. With such method at hand it is now possible to pass `stream.Duplex` instance as a `socket` parameter to `tls.connect()`. PR-URL: https://github.com/iojs/io.js/pull/926 Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
* stream_base: introduce StreamBaseFedor Indutny2015-02-221-27/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | StreamBase is an improved way to write C++ streams. The class itself is for separting `StreamWrap` (with the methods like `.writeAsciiString`, `.writeBuffer`, `.writev`, etc) from the `HandleWrap` class, making possible to write abstract C++ streams that are not bound to any uv socket. The following methods are important part of the abstraction (which mimics libuv's stream API): * Events: * `OnAlloc(size_t size, uv_buf_t*)` * `OnRead(ssize_t nread, const uv_buf_t*, uv_handle_type pending)` * `OnAfterWrite(WriteWrap*)` * Wrappers: * `DoShutdown(ShutdownWrap*)` * `DoTryWrite(uv_buf_t** bufs, size_t* count)` * `DoWrite(WriteWrap*, uv_buf_t*, size_t count, uv_stream_t* handle)` * `Error()` * `ClearError()` The implementation should provide all of these methods, thus providing the access to the underlying resource (be it uv handle, TLS socket, or anything else). A C++ stream may consume the input of another stream by replacing the event callbacks and proxying the writes. This kind of API is actually used now for the TLSWrap implementation, making it possible to wrap TLS stream into another TLS stream. Thus legacy API calls are no longer required in `_tls_wrap.js`. PR-URL: https://github.com/iojs/io.js/pull/840 Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
* src: switch from QUEUE to intrusive listBen Noordhuis2015-02-111-4/+5
| | | | | | | | | This commit also breaks up req_wrap.h into req-wrap.h and req-wrap-inl.h to work around a circular dependency issue in env.h. PR-URL: https://github.com/iojs/io.js/pull/667 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
* Remove excessive copyright/license boilerplateisaacs2015-01-121-21/+0
| | | | | | | 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.
* src: remove static variables from tls_wrapBen Noordhuis2014-11-181-7/+3
| | | | | | | | Remove the error message globals. More prep work for multi-isolate support. Reviewed-By: Fedor Indutny <fedor@indutny.com> PR-URL: https://github.com/node-forward/node/pull/58
* src: mark more destructors with override keywordBen Noordhuis2014-10-231-1/+1
| | | | | | The previous commits fixed oversights in destructors that should have been marked virtual but weren't. This commit marks destructors from derived classes with the override keyword.
* src: mark virtual functions with override keywordBen Noordhuis2014-10-231-7/+7
| | | | | | Add `override` keywords where appropriate. Makes maintenance easier because the compiler will shout at you when a base class changes in an incompatible way.
* src: replace NULL with nullptrBen Noordhuis2014-10-231-2/+2
| | | | | | | | | | Now that we are building with C++11 features enabled, replace use of NULL with nullptr. The benefit of using nullptr is that it can never be confused for an integral type because it does not support implicit conversions to integral types except boolean - unlike NULL, which is defined as a literal `0`.
* crypto: lower RSS usage for TLSCallbacksFedor Indutny2014-09-261-0/+6
| | | | | | | | | Don't allocate any BIO buffers initially, do this on a first read from the TCP connection. Allocate different amount of data for initial read and for consequent reads: small buffer for hello+certificate, big buffer for better throughput. see #8416
* tls_wrap: ensure that TLSCallbacks are gc-ableFedor Indutny2014-09-241-1/+2
| | | | | | | | Call `MakeWeak()` to destruct TLSCallbacks when the js-object dies. fix #8416 Reviewed-By: Fedor Indutny <fedor@indutny.com>
* crypto: make NewSessionDoneCb publicFedor Indutny2014-02-181-3/+2
| | | | | Generic friend classes do not work well with old compiler versions (and MSVC).
* tls: introduce asynchronous `newSession`Fedor Indutny2014-02-181-3/+13
| | | | fix #7105
* stream_wrap: use `uv_try_write` where possibleFedor Indutny2014-01-291-0/+1
| | | | | Use `uv_try_write` for string and buffer writes, thus avoiding to do allocations and copying in some of the cases.
* tls_wrap: propagate errors to write callbacksFedor Indutny2014-01-241-3/+12
| | | | fix #6903
* tls: process accumulated inputFedor Indutny2014-01-231-0/+1
| | | | | | | | 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
* Merge branch 'v0.10'Fedor Indutny2013-12-101-1/+5
| | | | | | | Conflicts: lib/tls.js src/node_crypto.cc src/node_crypto.h
* tls_wrap: bump kClearOutChunkSize to 16kbFedor Indutny2013-12-101-1/+1
|
* tls_wrap: use writev when possibleFedor Indutny2013-12-071-0/+3
| | | | Try writing multiple chunks from NodeBIO if possible.
* async-wrap: integrate with WeakObjectTrevor Norris2013-10-311-11/+3
| | | | | Making WeakObject inherit from AsyncWrap allows us to peak into almost all the MakeCallback calls in Node internals.
* src: remove ObjectWrap dependency from coreBen Noordhuis2013-09-251-6/+2
| | | | | | | | Drop the ObjectWrap dependency in favor of an internal WeakObject class. Let's us stop worrying about API and ABI compatibility when making changes to the way node.js deals with weakly persistent handles internally.
* src: add multi-context supportBen Noordhuis2013-09-061-3/+10
| | | | | | | | | | | | | | | | | | | | | | | This commit makes it possible to use multiple V8 execution contexts within a single event loop. Put another way, handle and request wrap objects now "remember" the context they belong to and switch back to that context when the time comes to call into JS land. This could have been done in a quick and hacky way by calling v8::Object::GetCreationContext() on the wrap object right before making a callback but that leaves a fairly wide margin for bugs. Instead, we make the context explicit through a new Environment class that encapsulates everything (or almost everything) that belongs to the context. Variables that used to be a static or a global are now members of the aforementioned class. An additional benefit is that this approach should make it relatively straightforward to add full isolate support in due course. There is no JavaScript API yet but that will be added in the near future. This work was graciously sponsored by GitHub, Inc.
* uv: upgrade to v0.11.12Ben Noordhuis2013-09-031-2/+4
| | | | | * upgrade deps/uv/ to v0.11.12. * update files in src/ after a libuv API change.
* tls, crypto: deduplicate codeFedor Indutny2013-08-191-53/+10
| | | | | | | | Commit 03e008d introduced src/tls_wrap.cc and src/tls_wrap.h but said files copied on the order of 1 kLoC from src/node_crypto.cc and src/node_crypto.h. This commit undoes some of the duplication. Fixes #6024.
* tls: asynchronous SNICallbackFedor Indutny2013-08-061-1/+3
| | | | | | | Make ClientHelloParser handle SNI extension, and extend `_tls_wrap.js` to support loading SNI Context from both hello, and resumed session. fix #5967
* tls_wrap: DRY ClientHelloParserFedor Indutny2013-08-061-24/+5
| | | | | | Share ClientHelloParser code between `tls_wrap.cc` and `node_crypto.cc`. fix #5959
* src: use PersistentToLocal() in a few more placesBen Noordhuis2013-08-031-3/+4
| | | | | | Update a few more `Local<T>::New(isolate, persistent)` call sites to `PersistentToLocal(isolate, persistent)` - the latter has a fast path for non-weak persistent references.
* lib, src: upgrade after v8 api changeBen Noordhuis2013-07-061-16/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a big commit that touches just about every file in the src/ directory. The V8 API has changed in significant ways. The most important changes are: * Binding functions take a const v8::FunctionCallbackInfo<T>& argument rather than a const v8::Arguments& argument. * Binding functions return void rather than v8::Handle<v8::Value>. The return value is returned with the args.GetReturnValue().Set() family of functions. * v8::Persistent<T> no longer derives from v8::Handle<T> and no longer allows you to directly dereference the object that the persistent handle points to. This means that the common pattern of caching oft-used JS values in a persistent handle no longer quite works, you first need to reconstruct a v8::Local<T> from the persistent handle with the Local<T>::New(isolate, persistent) factory method. A handful of (internal) convenience classes and functions have been added to make dealing with the new API a little easier. The most visible one is node::Cached<T>, which wraps a v8::Persistent<T> with some template sugar. It can hold arbitrary types but so far it's exclusively used for v8::Strings (which was by far the most commonly cached handle type.)
* build: fix include order for building on windowsTimothy J Fontaine2013-06-171-2/+2
| | | | fallout from the tls_wrap feature landing
* tls: session API returnsFedor Indutny2013-06-171-0/+41
|
* tls_wrap: embed TLS encryption into streamwrapFedor Indutny2013-06-161-0/+154