Skip to content

Commit 2679952

Browse files
authored
fix(tls): Skip TLS SNI if host is IP address (mqttjs#1311)
This avoids showing a warning when the broker address is just an IP [DEP0123] DeprecationWarning: Setting the TLS ServerName to an IP address is not permitted by RFC 6066. This will be ignored in a future version. Same fix as node-postgres has used brianc/node-postgres@d3c8eba
1 parent 6581d33 commit 2679952

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/connect/tls.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
'use strict'
22
var tls = require('tls')
3+
var net = require('net')
34
var debug = require('debug')('mqttjs:tls')
45

56
function buildBuilder (mqttClient, opts) {
67
var connection
78
opts.port = opts.port || 8883
89
opts.host = opts.hostname || opts.host || 'localhost'
9-
opts.servername = opts.host
10+
11+
if(net.isIP(opts.host) === 0){
12+
opts.servername = opts.host
13+
}
1014

1115
opts.rejectUnauthorized = opts.rejectUnauthorized !== false
1216

0 commit comments

Comments
 (0)