Skip to content

Already buffered data when creating a TLSSocket doesn't trigger/throw 'error' #1114

Closed
@jameshartig

Description

Brought over from nodejs/node-v0.x-archive#9355

If you pass a socket with already buffered data to TLSSocket and there's an error like:

[Error: 139745410942944:error:1408A0C1:SSL routines:SSL3_GET_CLIENT_HELLO:no shared cipher:s3_srvr.c:1352]

It will fire as a _tlsError immediately while in the constructor instead of either throwing an error (if there were no error handlers) or waiting till the next tick to fire the _tlsError.

This can be solved by wrapping this._init(socket) in a process.nextTick or delaying:

  // Socket already has some buffered data - emulate receiving it
  if (socket && socket._readableState.length) {
    var buf;
    while ((buf = socket.read()) !== null)
      this.ssl.receive(buf);
  }

It seems like the second option (delaying the initial buffer read) is better but let me know what you guys think.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    tlsIssues and PRs related to the tls subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions