node
node copied to clipboard
"Ambiguous" error with tls.connect() against a non-TLS listener
The following code will pass an "ambiguous" error object.
require('tls').connect(80, 'www.google.com', function() {
console.log('success');
}).on('error', function(error) {
console.log(error);
});
It is not (easily) determinable what the actual reason for the error was (refused connection, cipher problem or - as in this case - no TLS supported or something else).
Hi @user447463! Thanks for opening this issue. Unfortunately, the tls module doesn't handle errors well at all - it seems hard to serialize them from the OpenSSL bindings. This is definitely something we would like to see improved with a pull request (please submit one if you would like to help!), but unfortunately this issue isn't very actionable as is. I'll close for now. Thank you!