如何解决在连接到 Amazon RDS for MySQL 或 Aurora 数据库实例时出现的 ERROR 2026 SSL 连接错误?

3 分钟阅读
0

我尝试使用安全套接字层 (SSL) 连接到我的 Amazon Relational Database Service (Amazon RDS) 数据库实例或集群。我收到了以下错误: “ERROR 2026 (HY000): SSL connection error” 我该如何解决面向 Amazon RDS for MySQL、MySQL、Amazon Aurora 或 Amazon Aurora Serverless 的 ERROR 2026?

简短描述

ERROR 2026 有三种不同类型的错误消息:

  • ERROR 2026 (HY000): SSL connection error: SSL certificate validation failure(SSL 连接错误:SSL 证书验证失败)
  • ERROR 2026 (HY000): SSL connection error: Server doesn't support SSL(SSL 连接错误:服务器不支持 SSL)
  • ERROR 2026 (HY000): SSL connection error: ASN: bad other signature confirmation(SSL 连接错误:ASN:其他签名确认错误)

每种错误消息的详细问题排查步骤如下。

解决方法

ERROR 2026 (HY000): SSL connection error: SSL certificate validation failure(SSL 连接错误:SSL 证书验证失败)

要纠正此错误,请首先验证您使用的是集群终端节点还是数据库实例终端节点。有关 Amazon RDS 如何支持 SSL 的更多信息,请参阅将 SSL 与 MySQL 数据库实例配合使用将 SSL 与 Aurora MySQL 数据库集群配合使用

如果您使用支持主题替代名称 (SAN) 的客户端,则您只能使用集群终端节点。如果您的客户端不支持 SAN,则您必须使用主数据库实例终端节点。

**注意:**默认的 MySQL 命令行客户端不支持 SAN。

如果您在尝试连接到集群终端节点时收到此错误,则尝试连接到连接字符串中的主数据库实例终端节点。例如,您可以连接到集群终端节点。在以下示例中,集群终端节点是 abcdefg-clust.cluster-xxxx.us-east-1.rds.amazonaws.com。数据库实例终端节点为 abcdefg-inst.xxxx.us-east-1.rds.amazonaws.com

使用集群终端节点连接

[ec2-user@ip-192-0-2-0 ~]$ mysql -h abcdefg-clust.cluster-xxxx.us-east-1.rds.amazonaws.com --ssl-ca rds-combined-ca-bundle.pem --ssl-mode=VERIFY_IDENTITY -u test -p test
Enter password:
ERROR 2026 (HY000): SSL connection error: SSL certificate validation failure

使用数据库实例终端节点连接

[ec2-user@ip-192-0-2-0 ~]$ mysql -h abcdefg-inst.xxxx.us-east-1.rds.amazonaws.com --ssl-ca rds-combined-ca-bundle.pem 
--ssl-mode=VERIFY_IDENTITY -u test -p test
Enter password: 
Welcome to the MySQL monitor. Commands end with ; or \g. 
Your MySQL connection id is 26

ERROR 2026 (HY000): SSL connection error: Server doesn't support SSL(SSL 连接错误:服务器不支持 SSL)

如果您使用的服务器或引擎版本不支持 SSL,则您可能收到此错误。如要消除此错误,请迁移到支持 SSL 连接的引擎。

ERROR 2026 (HY000): SSL connection error: SSL_CTX_set_default_verify_paths failed(SSL 连接错误:SSL_CTX_set_default_verify_paths 失败)或 ERROR 2026 (HY000): SSL connection error: ASN: bad other signature confirmation(SSL 连接错误:ASN:其他签名确认错误)

如果证书标识符(证书文件名称)不正确,则您可能收到此错误。如果 MySQL 客户端(例如 Aurora Serverless)不支持该证书标识符,则您也可能会收到此错误。如果您使用 Aurora Serverless 集群,并且您使用 MySQL 客户端来连接到 Aurora Serverless,则您必须使用兼容 MySQL 8.0 的 MySQL 命令。

必须使用正确的证书标识符名称和正确的证书路径才能成功连接。连接之前,请确认您已下载正确的证书。有关更多信息,请参阅使用 SSL 加密与数据库实例的连接

根证书文件位于 Amazon Elastic Compute Cloud (Amazon EC2) 实例的下载目录 中。在以下示例中,由于您输入的路径错误,导致了 ERROR 2026

[ec2-user@ip-192-0-2-0 ~]$ mysql -h abcdefg-clust.cluster-xxxxx.us-east-1.rds.amazonaws.com --ssl-ca rds-combined-ca-bundle.pem --ssl-mode=VERIFY_IDENTITY -u test -p test
Enter password:
ERROR 2026 (HY000): SSL connection error: SSL_CTX_set_default_verify_paths failed

注意:此示例使用主目录中的连接字符串,但根证书位于下载目录中。

在以下示例中,您使用根证书的路径成功连接:

[ec2-user@ip-192-0-2-0 ~]$ mysql -h abcdefg-clust.cluster-xxxx.us-east-1.rds.amazonaws.com --ssl-ca /home/ec2-user/Downloads/rds-combined-ca-bundle.pem 
--ssl-mode=VERIFY_IDENTITY -u test -p test
Enter password: 
Welcome to the MySQL monitor. Commands end with ; or \g. 
Your MySQL connection id is 26

如果您不拥有存储证书的目录的权限,则您也可能会收到此错误。确保证书位于您有权访问的目录中。请参阅以下有关有权限和无权限连接的更多示例:

权限不足时连接

[ec2-user@ip-192-0-2-0 ~]$ sudo chmod 700 rds-combined-ca-bundle.pem 
[ec2-user@ip-192-0-2-0 ~]$ mysql -h abcdefg-inst.xxxx.us-east-1.rds.amazonaws.com --ssl-ca rds-combined-ca-bundle.pem --ssl-mode=VERIFY_IDENTITY -u test -p test
Enter password: 
ERROR 2026 (HY000): SSL connection error: SSL_CTX_set_default_verify_paths failed

拥有正确权限时连接

[ec2-user@ip-192-0-2-0 ~]$ sudo chmod 755 rds-combined-ca-bundle.pem
[ec2-user@ip-192-0-2-0 ~]$ mysql -h abcdefg-inst.xxxx.us-east-1.rds.amazonaws.com --ssl-ca rds-combined-ca-bundle.pem --ssl-mode=VERIFY_IDENTITY -u test -p test
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 810

相关信息

将 TLS/SSL 与 Aurora Serverless 结合使用

AWS 官方
AWS 官方已更新 3 年前