我正在运行一个 Google Cloud mySQL 实例,并指定了“仅允许 SSL 连接”。
当我使用以下方式连接时:
return mysql.createPool({
host: db_host,
port: 3306,
user: db_user,
password: db_password,
ssl: {
rejectUnauthorized: false,
key: clientKey,
cert: clientCert,
ca: serverCa,
},
});
...它工作正常,但是使用“rejectUnauthorized: false”显然不安全。 如果我删除“rejectUnauthorized: false”,我得到
'Hostname/IP does not match certificate's altnames: IP: ##.##.##.## is not in the cert's list:'
我已经尝试过了
nslookup ##.##.##.##
,这给了我一个名字。
当我尝试将其添加为主机名时,我得到:
Hostname/IP does not match certificate's altnames: Host: ##.##.##.##.bc.googleusercontent.com. is not in the cert's altnames: DNS:'##-########-####-####-####-########.australia-southeast2.sql.goog'
当我尝试添加 '##-########-####-####-####-########.australia-southeast2.sql.goog' 作为主机名,我得到:
'getaddrinfo ENOTFOUND ##-########-####-####-####-########.australia-southeast2.sql.goog'
我尝试过重新生成证书,但这没有什么区别。
我无法想象我是唯一需要从外部源连接到谷歌云 mySQL 实例的人,但是我在网上找不到任何解决方案。
我错过了一些明显的东西吗?