Skip to content

Fix server identity check #2253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
19 changes: 7 additions & 12 deletions lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,19 +365,14 @@ class Connection extends EventEmitter {
secureContext,
isServer: false,
socket: this.stream,
servername
}, () => {
secureEstablished = true;
if (rejectUnauthorized) {
if (typeof servername === 'string' && verifyIdentity) {
const cert = secureSocket.getPeerCertificate(true);
const serverIdentityCheckError = Tls.checkServerIdentity(servername, cert);
if (serverIdentityCheckError) {
onSecure(serverIdentityCheckError);
return;
}
servername,
checkServerIdentity: (servername, cert) => {
if (rejectUnauthorized && typeof servername === 'string' && verifyIdentity) {
return Tls.checkServerIdentity(servername, cert);
}
}
}, () => {
secureEstablished = true;
onSecure();
});
// error handler for secure socket
Expand Down Expand Up @@ -408,7 +403,7 @@ class Connection extends EventEmitter {
err.code = code || 'PROTOCOL_ERROR';
this.emit('error', err);
}

get fatalError() {
return this._fatalError;
}
Expand Down