使用 SSL/TLS 加密与数据库实例的连接 - Amazon Relational Database Service

使用 SSL/TLS 加密与数据库实例的连接

您可以使用应用程序中的安全套接字层 (SSL) 或传输层安全性 (TLS) 来加密与运行 MariaDB、Microsoft SQL Server、MySQL、Oracle 或 PostgreSQL 的数据库实例的连接。

SSL/TLS 连接通过加密可在您的客户端和数据库实例之间移动的数据来提供一个安全层。使用服务器证书可验证是否正在与 Amazon RDS 数据库实例建立连接,从而额外提供一层安全保护。具体方法是,检查自动安装在您预置的所有数据库实例上的服务器证书。

每个数据库引擎都有自己的用于实施 SSL/TLS 的过程。要了解如何为数据库实例实施 SSL/TLS,请使用与数据库引擎对应的以下链接:

注意

只能使用 SSL/TLS 连接下载所有证书。

证书颁发机构

证书颁发机构(CA)是用于标识证书链顶部的根 CA 的证书。CA 签署数据库实例证书,该证书是安装在每个数据库实例上的服务器证书。服务器证书将数据库实例标识为可信服务器。

Amazon RDS 提供以下 CA 来签署数据库实例的服务器证书。

证书颁发机构(CA) 描述

rds-ca-2019

将具有 RSA 2048 私有密钥算法和 SHA256 签名算法的证书颁发机构用于数据库实例服务器证书。此 CA 将于 2024 年到期,不支持服务器证书自动轮换。如果您正在使用此 CA 并希望保持相同的标准,我们建议您切换到 rds-ca-rsa2048-g1 CA。

rds-ca-rsa2048-g1

在大多数 AWS 区域中,将具有 RSA 2048 私有密钥算法和 SHA256 签名算法的证书颁发机构用于数据库实例服务器证书。

在 AWS GovCloud (US) Regions中,此 CA 将具有 RSA 2048 私有密钥算法和 SHA384 签名算法的证书颁发机构用于数据库实例服务器证书。

此 CA 的有效期比 rds-ca-2019 CA 长。此 CA 支持服务器证书自动轮换。

rds-ca-rsa4096-g1

将具有 RSA 4096 私有密钥算法和 SHA384 签名算法的证书颁发机构用于数据库实例服务器证书。此 CA 支持服务器证书自动轮换。

rds-ca-ecc384-g1

将具有 ECC 384 私有密钥算法和 SHA384 签名算法的证书颁发机构用于数据库实例服务器证书。此 CA 支持服务器证书自动轮换。

注意

如果您使用的是 AWS CLI,则可以使用 describe-certificates 查看上面列出的证书颁发机构的有效性。

当您在数据库实例中使用 rds-ca-rsa2048-g1、rds-ca-rsa4096-g1 或 rds-ca-ecc384-g1 CA 时,RDS 会管理数据库实例上的服务器证书。RDS 会在证书过期之前自动对其进行轮换。这些 CA 证书包含在区域和全球证书捆绑包中。

您可以在执行以下任务时为数据库实例设置 CA:

您可以使用 modify-certificates 命令为您的 AWS 账户设置原定设置 CA。

可用的 CA 取决于数据库引擎和数据库引擎版本。使用 AWS Management Console时,您可以使用 Certificate authority(证书颁发机构)设置选择 CA,如下图所示。


                    证书颁发机构选项

控制台仅显示可用于数据库引擎和数据库引擎版本的 CA。如果您使用的是 AWS CLI,则可以使用 create-db-instancemodify-db-instance 命令为数据库实例设置 CA。

如果您使用的是 AWS CLI,则可以使用 describe-certificates 命令查看您账户的可用 CA。此命令还在输出的 ValidTill 中显示每个 CA 的到期日期。您可以使用 describe-db-engine-versions 命令找到适用于特定数据库引擎和数据库引擎版本的 CA。

以下示例显示了可用于原定设置 RDS for PostgreSQL 数据库引擎版本的 CA。

aws rds describe-db-engine-versions --default-only --engine postgres

输出类似于以下内容。SupportedCACertificateIdentifiers 中列出了可用的 CA。输出还显示数据库引擎版本是否支持在 SupportsCertificateRotationWithoutRestart 中不重新启动的情况下轮换证书。

{ "DBEngineVersions": [ { "Engine": "postgres", "MajorEngineVersion": "13", "EngineVersion": "13.4", "DBParameterGroupFamily": "postgres13", "DBEngineDescription": "PostgreSQL", "DBEngineVersionDescription": "PostgreSQL 13.4-R1", "ValidUpgradeTarget": [], "SupportsLogExportsToCloudwatchLogs": false, "SupportsReadReplica": true, "SupportedFeatureNames": [ "Lambda" ], "Status": "available", "SupportsParallelQuery": false, "SupportsGlobalDatabases": false, "SupportsBabelfish": false, "SupportsCertificateRotationWithoutRestart": true, "SupportedCACertificateIdentifiers": [ "rds-ca-2019", "rds-ca-rsa2048-g1", "rds-ca-ecc384-g1", "rds-ca-rsa4096-g1" ] } ] }

您可以通过查看控制台中的 Connectivity & security(连接和安全)选项卡来查看有关数据库实例的 CA 的详细信息,如下图所示。


                    证书颁发机构详细信息

如果您使用的是 AWS CLI,您可以使用 describe-db-instances 命令,查看有关数据库实例的 CA 的详细信息。

所有 AWS 区域的证书捆绑包

要获取同时包含所有 AWS 区域的中间证书和根证书的证书捆绑包,请从 https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem 下载此捆绑包。

如果您的应用程序在 Microsoft Windows 上并且需要 PKCS7 文件,则可以下载 PKCS7 证书捆绑包。该捆绑包包含位于 https://truststore.pki.rds.amazonaws.com/global/global-bundle.p7b 的中间证书和根证书。

注意

Amazon RDS Proxy 使用来自 AWS Certificate Manager (ACM) 的证书。如果您正在使用 RDS Proxy,则无需下载 Amazon RDS 证书或更新使用 RDS Proxy 连接的应用程序。有关在 RDS Proxy 中使用 TLS/SSL 的更多信息,请参阅 将 TLS/SSL 与 RDS Proxy 结合使用

特定 AWS 区域的证书捆绑包

要获取包含 AWS 区域的中间证书和根证书的证书捆绑包,请通过下表中与 AWS 区域对应的链接下载此捆绑包。

AWS 区域 证书捆绑包 (PEM) 证书捆绑包 (PKCS7)
美国东部(弗吉尼亚北部) us-east-1-bundle.pem us-east-1-bundle.p7b
US East (Ohio) us-east-2-bundle.pem us-east-2-bundle.p7b
美国西部(加利福尼亚北部) us-west-1-bundle.pem us-west-1-bundle.p7b
美国西部(俄勒冈) us-west-2-bundle.pem us-west-2-bundle.p7b
Africa (Cape Town) af-south-1-bundle.pem af-south-1-bundle.p7b
Asia Pacific (Hong Kong) ap-east-1-bundle.pem ap-east-1-bundle.p7b
亚太地区(海得拉巴) ap-south-2-bundle.pem ap-south-2-bundle.p7b
亚太地区(雅加达) ap-southeast-3-bundle.pem ap-southeast-3-bundle.p7b
亚太地区(墨尔本) ap-southeast-4-bundle.pem ap-southeast-4-bundle.p7b
亚太地区(孟买) ap-south-1-bundle.pem ap-south-1-bundle.p7b
Asia Pacific (Osaka) ap-northeast-3-bundle.pem ap-northeast-3-bundle.p7b
亚太区域(东京) ap-northeast-1-bundle.pem ap-northeast-1-bundle.p7b
Asia Pacific (Seoul) ap-northeast-2-bundle.pem ap-northeast-2-bundle.p7b
亚太地区(新加坡) ap-southeast-1-bundle.pem ap-southeast-1-bundle.p7b
亚太地区(悉尼) ap-southeast-2-bundle.pem ap-southeast-2-bundle.p7b
Canada (Central) ca-central-1-bundle.pem ca-central-1-bundle.p7b
Europe (Frankfurt) eu-central-1-bundle.pem eu-central-1-bundle.p7b
欧洲(爱尔兰) eu-west-1-bundle.pem eu-west-1-bundle.p7b
Europe (London) eu-west-2-bundle.pem eu-west-2-bundle.p7b
Europe (Milan) eu-south-1-bundle.pem eu-south-1-bundle.p7b
Europe (Paris) eu-west-3-bundle.pem eu-west-3-bundle.p7b
欧洲(西班牙) eu-south-2-bundle.pem eu-south-2-bundle.p7b
欧洲(斯德哥尔摩) eu-north-1-bundle.pem eu-north-1-bundle.p7b
欧洲(苏黎世) eu-central-2-bundle.pem eu-central-2-bundle.p7b
中东(巴林) me-south-1-bundle.pem me-south-1-bundle.p7b
中东(阿联酋) me-central-1-bundle.pem me-central-1-bundle.p7b
南美洲(圣保罗) sa-east-1-bundle.pem sa-east-1-bundle.p7b

AWS GovCloud (US) 证书

要获取同时包含 AWS GovCloud (US) Region 的中间证书和根证书的证书捆绑包,请从 https://truststore.pki.us-gov-west-1.rds.amazonaws.com/global/global-bundle.pem 下载。

如果您的应用程序在 Microsoft Windows 上并且需要 PKCS7 文件,则可以下载 PKCS7 证书捆绑包。该捆绑包包含位于 https://truststore.pki.us-gov-west-1.rds.amazonaws.com/global/global-bundle.p7b 的中间证书和根证书。

要获取包含 AWS GovCloud (US) Region 的中间证书和根证书的证书捆绑包,请通过下表中 AWS GovCloud (US) Region 对应的链接下载。

AWS GovCloud (US) Region 证书捆绑包 (PEM) 证书捆绑包 (PKCS7)
AWS GovCloud(美国东部) us-gov-east-1-bundle.pem us-gov-east-1-bundle.p7b
AWS GovCloud(美国西部) us-gov-west-1-bundle.pem us-gov-west-1-bundle.p7b