Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Allow tls.connect to start on server-side sockets and add tls.start as a simple wrapper for tls.connect #3653

Closed
wants to merge 4 commits into from

Conversation

Rush
Copy link

@Rush Rush commented Jul 6, 2012

I have found a piece of code floating on the internet to initiate a TLS function in the middle of a TCP connection, but the code in question has not functioned well. I decided to look into tls.js module whether it can do it all with some minor adjustment.

There was a previous pull request for this function #848
However, current state of connect does not allow to start TLS arbitralily on a server-side socket.

Thus, I propose a very simple change to tls.connect allowing to say whether we want a server side socket via options.asServer but also I add a very nice intuitive wrapper called tls.start and two tests.

tls.start is in the same style as child_process.fork so I think it fits together inside node.

I am willing to update documention if a green light is given to this improvements.

@@ -1119,7 +1119,8 @@ exports.connect = function(/* [port, host], options, cb */) {
var sslcontext = crypto.createCredentials(options);

convertNPNProtocols(options.NPNProtocols, this);
var pair = new SecurePair(sslcontext, false, true,

var pair = new SecurePair(sslcontext, options.asServer?true:false, true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style.

@Nodejs-Jenkins
Copy link

Can one of the admins verify this patch?

@tjfontaine
Copy link

This should be implemented in the current unstable, thanks!

@tjfontaine tjfontaine closed this Feb 18, 2014
richardlau pushed a commit to ibmruntimes/node that referenced this pull request Dec 15, 2015
Fix node exiting due to an exception being thrown rather than emitting
an `'uncaughtException'` event on the process object when:
1. no error handler is set on the domain within which an error is thrown
2. an `'uncaughtException'` event listener is set on the process

Also fix an issue where the process would not abort in the proper
function call if an error is thrown within a domain with no error
handler and `--abort-on-uncaught-exception` is used.

Finally, change the behavior of --abort-on-uncaught-exception so that,
if the domain within which the error is thrown has no error handler, but
a domain further up the domains stack has one, the process will not
abort.

Fixes nodejs#3607 and nodejs#3653.

PR: nodejs#3654
PR-URL: nodejs/node#3654
Reviewed-By: Chris Dickinson <[email protected]>
richardlau pushed a commit to ibmruntimes/node that referenced this pull request Dec 17, 2015
Fix node exiting due to an exception being thrown rather than emitting
an 'uncaughtException' event on the process object when:
1. no error handler is set on the domain within which an error is thrown
2. an 'uncaughtException' event listener is set on the process

Also fix an issue where the process would not abort in the proper
function call if an error is thrown within a domain with no error
handler and --abort-on-uncaught-exception is used.

Fixes nodejs#3607 and nodejs#3653.

PR: nodejs#3887
PR-URL: nodejs/node#3887
Reviewed-By: James M Snell <[email protected]>
richardlau pushed a commit to ibmruntimes/node that referenced this pull request Dec 17, 2015
Fix node exiting due to an exception being thrown rather than emitting
an 'uncaughtException' event on the process object when:
1. no error handler is set on the domain within which an error is thrown
2. an 'uncaughtException' event listener is set on the process

Also fix an issue where the process would not abort in the proper
function call if an error is thrown within a domain with no error
handler and --abort-on-uncaught-exception is used.

Fixes nodejs#3607 and nodejs#3653.

PR: nodejs#3885
PR-URL: nodejs/node#3885
Reviewed-By: James M Snell <[email protected]>
richardlau pushed a commit to ibmruntimes/node that referenced this pull request Dec 17, 2015
Fix node exiting due to an exception being thrown rather than emitting
an `'uncaughtException'` event on the process object when:
1. no error handler is set on the domain within which an error is thrown
2. an `'uncaughtException'` event listener is set on the process

Also fix an issue where the process would not abort in the proper
function call if an error is thrown within a domain with no error
handler and `--abort-on-uncaught-exception` is used.

Fixes nodejs#3607 and nodejs#3653.

PR: nodejs#3884
PR-URL: nodejs/node#3884
Reviewed-By: James M Snell <[email protected]>
richardlau pushed a commit to ibmruntimes/node that referenced this pull request Dec 18, 2015
Fix node exiting due to an exception being thrown rather than emitting
an `'uncaughtException'` event on the process object when:
1. no error handler is set on the domain within which an error is thrown
2. an `'uncaughtException'` event listener is set on the process

Also fix an issue where the process would not abort in the proper
function call if an error is thrown within a domain with no error
handler and `--abort-on-uncaught-exception` is used.

Fixes nodejs#3607 and nodejs#3653.

PR: nodejs#3884
PR-URL: nodejs/node#3884
Reviewed-By: James M Snell <[email protected]>
richardlau pushed a commit to ibmruntimes/node that referenced this pull request Jan 11, 2016
Fix node exiting due to an exception being thrown rather than emitting
an `'uncaughtException'` event on the process object when:
1. no error handler is set on the domain within which an error is thrown
2. an `'uncaughtException'` event listener is set on the process

Also fix an issue where the process would not abort in the proper
function call if an error is thrown within a domain with no error
handler and `--abort-on-uncaught-exception` is used.

Fixes nodejs#3607 and nodejs#3653.

PR: nodejs#3884
PR-URL: nodejs/node#3884
Reviewed-By: James M Snell <[email protected]>
richardlau pushed a commit to ibmruntimes/node that referenced this pull request Jan 13, 2016
Fix node exiting due to an exception being thrown rather than emitting
an `'uncaughtException'` event on the process object when:
1. no error handler is set on the domain within which an error is thrown
2. an `'uncaughtException'` event listener is set on the process

Also fix an issue where the process would not abort in the proper
function call if an error is thrown within a domain with no error
handler and `--abort-on-uncaught-exception` is used.

Finally, change the behavior of --abort-on-uncaught-exception so that,
if the domain within which the error is thrown has no error handler, but
a domain further up the domains stack has one, the process will not
abort.

Fixes nodejs#3607 and nodejs#3653.

PR: nodejs#3654
PR-URL: nodejs/node#3654
Reviewed-By: Chris Dickinson <[email protected]>
richardlau pushed a commit to ibmruntimes/node that referenced this pull request Feb 15, 2016
Fix node exiting due to an exception being thrown rather than emitting
an 'uncaughtException' event on the process object when:
1. no error handler is set on the domain within which an error is thrown
2. an 'uncaughtException' event listener is set on the process

Also fix an issue where the process would not abort in the proper
function call if an error is thrown within a domain with no error
handler and --abort-on-uncaught-exception is used.

Fixes nodejs#3607 and nodejs#3653.

PR: nodejs#3885
PR-URL: nodejs/node#3885
Reviewed-By: James M Snell <[email protected]>
richardlau pushed a commit to ibmruntimes/node that referenced this pull request Feb 15, 2016
Fix node exiting due to an exception being thrown rather than emitting
an 'uncaughtException' event on the process object when:
1. no error handler is set on the domain within which an error is thrown
2. an 'uncaughtException' event listener is set on the process

Also fix an issue where the process would not abort in the proper
function call if an error is thrown within a domain with no error
handler and --abort-on-uncaught-exception is used.

Fixes nodejs#3607 and nodejs#3653.

PR: nodejs#3887
PR-URL: nodejs/node#3887
Reviewed-By: James M Snell <[email protected]>
jBarz pushed a commit to ibmruntimes/node that referenced this pull request Nov 4, 2016
Fix node exiting due to an exception being thrown rather than emitting
an 'uncaughtException' event on the process object when:
1. no error handler is set on the domain within which an error is thrown
2. an 'uncaughtException' event listener is set on the process

Also fix an issue where the process would not abort in the proper
function call if an error is thrown within a domain with no error
handler and --abort-on-uncaught-exception is used.

Fixes nodejs#3607 and nodejs#3653.

PR: nodejs#3885
PR-URL: nodejs/node#3885
Reviewed-By: James M Snell <[email protected]>
jBarz pushed a commit to ibmruntimes/node that referenced this pull request Feb 16, 2017
Fix node exiting due to an exception being thrown rather than emitting
an 'uncaughtException' event on the process object when:
1. no error handler is set on the domain within which an error is thrown
2. an 'uncaughtException' event listener is set on the process

Also fix an issue where the process would not abort in the proper
function call if an error is thrown within a domain with no error
handler and --abort-on-uncaught-exception is used.

Fixes nodejs#3607 and nodejs#3653.

PR: nodejs#3885
PR-URL: nodejs/node#3885
Reviewed-By: James M Snell <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants