Skip to content

Commit 06fbe19

Browse files
jrmerzbrianc
authored andcommitted
Skip TLS SNI if host is IP address (#1890)
* skip TLS SNI if host is IP address (do not set servername option in tls.connect) * Format code
1 parent cd66c0b commit 06fbe19

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/connection.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,8 @@ Connection.prototype.connect = function (port, host) {
9191
return self.emit('error', new Error('There was an error establishing an SSL connection'))
9292
}
9393
var tls = require('tls')
94-
self.stream = tls.connect({
94+
const options = {
9595
socket: self.stream,
96-
servername: host,
9796
checkServerIdentity: self.ssl.checkServerIdentity || tls.checkServerIdentity,
9897
rejectUnauthorized: self.ssl.rejectUnauthorized,
9998
ca: self.ssl.ca,
@@ -103,7 +102,11 @@ Connection.prototype.connect = function (port, host) {
103102
cert: self.ssl.cert,
104103
secureOptions: self.ssl.secureOptions,
105104
NPNProtocols: self.ssl.NPNProtocols
106-
})
105+
}
106+
if (net.isIP(host) === 0) {
107+
options.servername = host
108+
}
109+
self.stream = tls.connect(options)
107110
self.attachListeners(self.stream)
108111
self.stream.on('error', reportStreamError)
109112

0 commit comments

Comments
 (0)