-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
IP hosts are not validated correctly against certificate altnames #2263
Comments
Related to brianc/node-postgres-docs#79 |
We encountered the same issue when using sequelize to connect to PG database. It's blocking us from moving forward with changing DB connection architecture. @RazerM @charmander |
The TLS issue can be demonstrated with https://1.1.1.1: const net = require('net');
const tls = require('tls');
function connect(port, host) {
const stream = new net.Socket();
stream.connect(port, host);
const options = {
socket: stream,
// host,
};
tls.connect(options);
}
connect(443, '1.1.1.1');
Uncommenting the |
Was pulling my hair out about this issue. Am putting a solution here since search engines seem to find it. Not sure if this is the 100% best fix (but much better than rejectUnauthorized=false). My Error: Fix:
Adding the expected DNS value in the error (I thought it would be in the cert too but I can't see it with openssl) as the servername makes the certs not try to verify against localhost. |
For example, connecting to IP 1.2.3.4 yields the following error:
Since TLS support was added to pg, it has passed a socket to
tls.connect
, meaning the host should be passed separately (it isn't). It passedservername
, which is not valid for IP addresses and was removed in #1890.The reason that the error message above uses localhost can be found in
_tls_wrap.js
.I found a previous issue (#2178) about this but it wasn't fixed. The correct fix is to always pass
host
. The documentation foroptions.socket
says:I can submit a PR but I will need help if you'd like a test for this.
The text was updated successfully, but these errors were encountered: