尝试通过 mysql CLI 连接到 mysql Aurora 时出现 SSL 连接错误

SSL connection error when trying to connect to mysql Aurora via the mysql CLI

我会先说当我不尝试通过 SSL 时我可以连接到数据库实例。

我在此处遵循本指南

http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Aurora.Connect.html

我已确保数据库实例 public 面向。

VPC的安全组规则如下:

Type Protocol Port Range Source
MySQL/Aurora (3306) TCP (6) 3306 my_ip_address/32
MySQL/Aurora (3306) TCP (6) 3306 sg-security_group_name

其中 security_group_name 是我的 EC2 集群的安全组。

我正在使用我的 aurora 集群的集群端点。我已经删除了端口。我使用自制软件在 machine 上安装了 mysql。这是我从本地 machine (macbook):

尝试的命令
mysql -h blah-database-cluster.cluster-dfgdgfd.us-east-1.rds.amazonaws.com --ssl-ca=rds-ssl-ca-cert.pem --ssl-verify-server-cert

其中rds-ssl-ca-cert.pem是我从这里下载的文件:

http://s3.amazonaws.com/rds-downloads/rds-ssl-ca-cert.pem

我收到错误:

ERROR 2026 (HY000): SSL connection error: error:00000001:lib(0):func(0):reason(1)

我试过创建新实例、重新启动等,但没有成功。我的安全组是否需要某种 https 规则?

编辑:

进一步的线索。当我 运行 mysql --ssl 在本地时它不会出错。但是当我执行 mysql show_variables 时,它说 SSL false 并且 have_ssl 和 have_open_ssl 变量不存在。这可能是问题所在吗?我通过 mac.

的自制程序包管理器安装了本地 mysql

新编辑:

我重新安装了 mysql(以前来自 brew),现在直接从 oracle 安装,当我尝试连接它时 给出了不同的错误 - SSL 连接错误:ASN:其他签名错误确认

  1. 目前 AWS Aurora 文档链接到要使用的过时 SSL 证书,因此出现了问题。这已得到 AWS 支持人员的确认。改用这个:https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem

  2. 即使使用该证书,通过 SSL 连接到集群端点对于使用 mysql -h 连接的命令行仍然不起作用。如果我奇怪地从集群端点更改为实例端点,它会起作用。

  3. 奇怪的是,mysql workbench 确实通过 ssl 连接到实例端点和集群端点。

docs 看来,对 SSL 连接实例端点的限制是与证书关联的安全约束。

Amazon RDS creates an SSL certificate and installs the certificate on the DB instance when Amazon RDS provisions the instance. These certificates are signed by a certificate authority. The SSL certificate includes the DB instance endpoint as the Common Name (CN) for the SSL certificate to guard against spoofing attacks. As a result, you cannot use the DB cluster endpoint to connect to the primary instance of the DB cluster using SSL.

如果您不使用 SSL.If,请将 mysql 与 --skip-ssl 选项一起使用 SSL.If 没有任何帮助升级您的 mysql 客户端

仅供参考 请也尝试使用此密钥(来自 Amazon 文档)

https://s3.amazonaws.com/rds-downloads/rds-ca-2015-root.pem

https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.SSL.html

对我来说,我必须使用:

mysql --ssl-mode=DISABLED -u [USER] -p[PASSWORD] -h [HOST] [DB]