Get Hands-on with Amazon EKS - Workshop Event Series
Whether you're taking your first steps with Kubernetes or you're an experienced practitioner looking to sharpen your skills, our Amazon EKS workshop series delivers practical, real-world experience that moves you forward. Learn directly from AWS solutions architects and EKS specialists through hands-on sessions designed to build your confidence with Kubernetes. Register now and start building with Amazon EKS!
如何解決在連線到 Amazon RDS for MySQL 或 Aurora 資料庫執行個體時,發生的「ERROR 2026 SSL connection」錯誤?
我想要使用 SSL/TLS 連線至我的 Amazon Relational Database Service (Amazon RDS) MySQL 資料庫執行個體或叢集。但我收到以下錯誤訊息: 「ERROR 2026 (HY000): SSL connection error.」
解決方法
使用以下疑難排解步驟來解決您收到的錯誤。
**注意:**在以下命令範例中,叢集端點為 abcdefg-clust.cluster-xxxx.us-east-1.rds.amazonaws.com。而資料庫執行個體端點為 abcdefg-inst.xxxx.us-east-1.rds.amazonaws.com。
SSL 憑證驗證失敗
若要疑難排解此錯誤,請先確認您使用的是叢集端點還是資料庫執行個體端點。如需更多資訊,請參閱 Amazon RDS for MySQL 或使用 SSL/TLS 加密連線至資料庫叢集。
如果您使用的用戶端支援主體替代名稱 (SAN),則只能使用叢集端點。如果您的用戶端不支援 SAN,則必須使用主要資料庫執行個體的端點。
**注意:**預設的 MySQL 命令列用戶端不支援 SAN。
如果您在嘗試連線至叢集端點時收到 SSL 憑證驗證錯誤,請改為連線至主要資料庫執行個體的端點。
使用叢集端點進行連線的命令範例:
[ec2-user@ip-192-0-2-0 ~]$ mysql -h abcdefg-clust.cluster-xxxx.us-east-1.rds.amazonaws.com --ssl-ca global-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 rglobal-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
伺服器不支援 SSL
當您使用的伺服器或引擎版本不支援 SSL/TLS 時,就會收到此錯誤。若要解決此錯誤,請遷移至支援 SSL/TLS 連線的引擎。
SSL_CTX_set_default_verify_paths failed
當憑證檔案不存在、檔案路徑不正確,或您沒有讀取該檔案的權限時,就會收到此錯誤。如果您沒有存取儲存憑證檔案之目錄的權限,也可能會收到此錯誤。請確保憑證檔案位於您有權限存取的目錄中。
在連線前,請確認您已下載正確的憑證。在進行連線時,請確認您使用的是正確的憑證識別名稱,以及正確的憑證路徑。
全域套件憑證檔案位於 Amazon Elastic Compute Cloud (Amazon EC2) 執行個體的 Downloads 目錄中。
使用錯誤的全域套件憑證路徑進行連線的命令範例:
[ec2-user@ip-192-0-2-0 ~]$ mysql -h abcdefg-clust.cluster-xxxxx.us-east-1.rds.amazonaws.com --ssl-ca global-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/global-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 global-bundle.pem [ec2-user@ip-192-0-2-0 ~]$ mysql -h abcdefg-inst.xxxx.us-east-1.rds.amazonaws.com --ssl-ca global-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 global-bundle.pem [ec2-user@ip-192-0-2-0 ~]$ mysql -h abcdefg-inst.xxxx.us-east-1.rds.amazonaws.com --ssl-ca global-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
SSL 連線錯誤:error:00000001:lib(0)::reason(1)
在以下情況中,您會收到此連線錯誤:
- 您使用了不正確的憑證檔案。
- 憑證檔案與 RDS 執行個體所需的憑證不相符。
- MySQL 用戶端不支援該憑證識別名稱。
**注意:**對於 MySQL 相容版 Aurora Serverless 資料庫叢集,您必須使用與 MySQL 8.0 相容的命令。
在連線前,請確認您已下載正確的憑證。在進行連線時,請確認您使用的是正確的憑證識別名稱,以及正確的憑證路徑。
使用不正確憑證而嘗試連線至資料庫執行個體端點的命令範例:
[ec2-user@ip-192-0-2-0 ~]$ mysql -habcdefg-inst.xxxx.us-east-1.rds.amazonaws.com --ssl-ca rds-ca-2019-root.pem --ssl-mode=VERIFY_IDENTITY -u test -p Enter password: ERROR 2026 (HY000): SSL connection error: error:00000001:lib(0)::reason(1)
使用正確憑證並成功連線至資料庫執行個體的命令範例:
[ec2-user@ip-192-0-2-0 ~]$ mysql -h abcdefg-inst.xxxx.us-east-1.rds.amazonaws.com --ssl-ca global-bundle.pem --ssl-mode=VERIFY_IDENTITY -u admin -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g.
相關資訊
相關內容
- 已提問 1 年前

