Skip to content
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

Skip TLS SNI if host is IP address #1311

Merged
merged 1 commit into from
Dec 13, 2021
Merged
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
6 changes: 5 additions & 1 deletion lib/connect/tls.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
'use strict'
var tls = require('tls')
var net = require('net')
var debug = require('debug')('mqttjs:tls')

function buildBuilder (mqttClient, opts) {
var connection
opts.port = opts.port || 8883
opts.host = opts.hostname || opts.host || 'localhost'
opts.servername = opts.host

if(net.isIP(opts.host) === 0){
Copy link
Contributor

Choose a reason for hiding this comment

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

so can you explain what is happening here in detail? You're checking if the passed in option on host is an IP address? And then the reason for this is because of something to do with TLS SNI?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the server doesn't have a name but only an IP Address in the config then this doesn't try set that IP as the servername for TLS purposes. This avoids a warning at startup

opts.servername = opts.host
}

opts.rejectUnauthorized = opts.rejectUnauthorized !== false

Expand Down