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

Ignore path when connect as MQTTS. #700

Merged
merged 2 commits into from
Oct 16, 2017
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions lib/connect/tls.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ function buildBuilder (mqttClient, opts) {

opts.rejectUnauthorized = opts.rejectUnauthorized !== false

delete opts.path

connection = tls.connect(opts)
/* eslint no-use-before-define: [2, "nofunc"] */
connection.on('secureConnect', function () {
Expand Down
30 changes: 30 additions & 0 deletions test/secure_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,36 @@ describe('MqttSecureClient', function () {
})
})

it('should validate successfully the CA using URI', function (done) {
var client = mqtt.connect('mqtts://localhost:' + port, {
ca: [fs.readFileSync(CERT)],
rejectUnauthorized: true
})

client.on('error', function (err) {
done(err)
})

server.once('connect', function () {
done()
})
})

it('should validate successfully the CA using URI with path', function (done) {
var client = mqtt.connect('mqtts://localhost:' + port + '/', {
ca: [fs.readFileSync(CERT)],
rejectUnauthorized: true
})

client.on('error', function (err) {
done(err)
})

server.once('connect', function () {
done()
})
})

it('should validate unsuccessfully the CA', function (done) {
var client = mqtt.connect({
protocol: 'mqtts',
Expand Down