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

got warning when host is an IP address #2588

Open
avispeng opened this issue Apr 11, 2024 · 1 comment
Open

got warning when host is an IP address #2588

avispeng opened this issue Apr 11, 2024 · 1 comment

Comments

@avispeng
Copy link

avispeng commented Apr 11, 2024

Hello.

We use knex and mysql2 to connect to Google Cloud SQL from a local machine.

knex: v3.1.0
mysql2: 3.9.4

const knex = require('knex');
const fs = require('fs');

const params = {
  client: 'mysql2',
  connection: {
    user: "db user",
    password: "db password",
    database: "db name",
    timezone: 'Z',
    host: "public IP address of db",
    ssl: {
      ca: fs.readFileSync(__dirname + '/server-ca.pem'),
      cert: fs.readFileSync(__dirname + '/client-cert.pem'),
      key: fs.readFileSync(__dirname + '/client-key.pem'),
    }
  },
};

const knexInstance = knex(params);

The issue is, when the host is an IP address (provided by Google Cloud SQL), we get warning

[DEP0123] DeprecationWarning: Setting the TLS ServerName to an IP address is not permitted by RFC 6066. This will be ignored in a future version.

It seems that the cause is the host is passed as servername in the call of tls.connect(), and according to https://nodejs.org/api/tls.html#tlsconnectoptions-callback

servername: Server name for the SNI (Server Name Indication) TLS extension. It is the name of the host being connected to, and must be a host name, and not an IP address.

I am wondering what would be the correct approach to resolve this issue? Thank you.

@sidorares
Copy link
Owner

linking related #2560

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants