Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,11 @@ function oncertcb(info) {
if (!self._handle)
return self.destroy(new Error('Socket is closed'));

self._handle.certCbDone();
try {
self._handle.certCbDone();
} catch (e) {
self.destroy(e);
}
});
});
}
Expand Down
42 changes: 42 additions & 0 deletions test/parallel/test-tls-empty-sni-context.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use strict';

if (!process.features.tls_sni) {
console.log('1..0 # Skipped: node compiled without OpenSSL or ' +
'with old OpenSSL version.');
return;
}

const common = require('../common');
const assert = require('assert');

if (!common.hasCrypto) {
console.log('1..0 # Skipped: missing crypto');
return;
}

const tls = require('tls');

const options = {
SNICallback: (name, callback) => {
callback(null, tls.createSecureContext());
}
};

const server = tls.createServer(options, (c) => {
assert(false, 'Should not be called');
Copy link
Member

Choose a reason for hiding this comment

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

common.fail

Copy link
Member Author

Choose a reason for hiding this comment

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

Ack.

}).on('tlsClientError', common.mustCall((err, c) => {
assert(/SSL_use_certificate:passed a null parameter/i.test(err.message));
server.close();
})).listen(common.PORT, common.mustCall(() => {
const c = tls.connect({
port: common.PORT,
rejectUnauthorized: false,
servername: 'any.name'
}, () => {
assert(false, 'Should not be called');
Copy link
Member

Choose a reason for hiding this comment

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

Ditto.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ack.

});

c.on('error', common.mustCall((err) => {
assert(err);
Copy link
Member

Choose a reason for hiding this comment

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

Why don't you check err.message?

Copy link
Member Author

Choose a reason for hiding this comment

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

It doesn't contain anything useful. Just ECONNRESET or socket hang up

Copy link
Member

Choose a reason for hiding this comment

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

It's still good to check that you're getting the error you're expecting, IMO.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ack.

}));
}));