node-mysql2 icon indicating copy to clipboard operation
node-mysql2 copied to clipboard

Error [ERR_TLS_CERT_ALTNAME_INVALID]: Hostname/IP does not match certificate's altnames

Open Jooeee opened this issue 2 years ago • 1 comments

Im trying to connect to a Google Cloud Platform MySQL instance with SSL enabled using a public IP. However I get the error:

Error: Error [ERR_TLS_CERT_ALTNAME_INVALID]: Hostname/IP does not match certificate's altnames: IP: xx.xx.xxx.xx is not in the cert's list

If I set reject unauthorised to false it works correctly.

There is no way to add the IP to the altnames because Google generates the certificates automatically. I also can't connect to the instance using a hostname because that isn't supported by Google. I've tried adding checkServerIdentity: () => null to the ssl options but get the same results. Is there any secure work around to this?

Jooeee avatar Aug 16 '23 16:08 Jooeee

unfortunately checkServerIdentity can't be passed from the config yet, but I plan to add that

linking related issue: https://github.com/sidorares/node-mysql2/issues/2172

sidorares avatar Aug 17 '23 06:08 sidorares