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

Deprecate implicit TLS rejectUnauthorized: false #2075

Merged
merged 1 commit into from Jan 15, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/pg/lib/compat/warn-deprecation.js
Expand Up @@ -5,7 +5,7 @@ const util = require('util')
const dummyFunctions = new Map()

// Node 4 doesn’t support process.emitWarning(message, 'DeprecationWarning', code).
const emitDeprecationWarning = (message, code) => {
const warnDeprecation = (message, code) => {
let dummy = dummyFunctions.get(code)

if (dummy === undefined) {
Expand All @@ -16,4 +16,4 @@ const emitDeprecationWarning = (message, code) => {
dummy()
}

module.exports = emitDeprecationWarning
module.exports = warnDeprecation
5 changes: 5 additions & 0 deletions packages/pg/lib/connection-fast.js
Expand Up @@ -15,6 +15,8 @@ var Writer = require('buffer-writer')
// eslint-disable-next-line
var PacketStream = require('pg-packet-stream')

var warnDeprecation = require('./compat/warn-deprecation')

var TEXT_MODE = 0

// TODO(bmc) support binary mode here
Expand Down Expand Up @@ -105,6 +107,9 @@ Connection.prototype.connect = function (port, host) {
secureOptions: self.ssl.secureOptions,
NPNProtocols: self.ssl.NPNProtocols
}
if (typeof self.ssl.rejectUnauthorized !== 'boolean') {
warnDeprecation('Implicit disabling of certificate verification is deprecated and will be removed in pg 8. Specify `rejectUnauthorized: true` to require a valid CA or `rejectUnauthorized: false` to explicitly opt out of MITM protection.', 'PG-SSL-VERIFY')
}
if (net.isIP(host) === 0) {
options.servername = host
}
Expand Down
5 changes: 5 additions & 0 deletions packages/pg/lib/connection.js
Expand Up @@ -14,6 +14,8 @@ var util = require('util')
var Writer = require('buffer-writer')
var Reader = require('packet-reader')

var warnDeprecation = require('./compat/warn-deprecation')

var TEXT_MODE = 0
var BINARY_MODE = 1
var Connection = function (config) {
Expand Down Expand Up @@ -103,6 +105,9 @@ Connection.prototype.connect = function (port, host) {
secureOptions: self.ssl.secureOptions,
NPNProtocols: self.ssl.NPNProtocols
}
if (typeof self.ssl.rejectUnauthorized !== 'boolean') {
warnDeprecation('Implicit disabling of certificate verification is deprecated and will be removed in pg 8. Specify `rejectUnauthorized: true` to require a valid CA or `rejectUnauthorized: false` to explicitly opt out of MITM protection.', 'PG-SSL-VERIFY')
}
if (net.isIP(host) === 0) {
options.servername = host
}
Expand Down