

# 使用加密保护数据
<a name="Encryption"></a>

Amazon Aurora 对存储层的数据库资源进行加密。您也可以加密与数据库集群的连接。

**Topics**
+ [加密 Amazon Aurora 资源](Overview.Encryption.md)
+ [AWS KMS key 管理](Overview.Encryption.Keys.md)
+ [使用 SSL/TLS 加密与数据库集群的连接](UsingWithRDS.SSL.md)
+ [轮换 SSL/TLS 证书](UsingWithRDS.SSL-certificate-rotation.md)

# 加密 Amazon Aurora 资源
<a name="Overview.Encryption"></a>

无论是在本地客户端和 Amazon Aurora 之间，还是在 Amazon Aurora 和其他 AWS 资源之间移动，Amazon Aurora 都能保护您的静态数据和传输中数据。Amazon Aurora 会加密您的 Amazon Aurora 数据库集群中的所有用户数据，包括日志、自动备份和快照。

在加密数据后，Amazon Aurora 将以透明方式处理访问的身份验证和数据的解密，并且对性能产生的影响最小。您无需修改数据库客户端应用程序来使用加密。

**注意**  
对于加密和未加密数据库集群，将对在源与只读副本之间发送的数据进行加密，即使在 AWS 区域之间复制时也是如此。

**Topics**
+ [Amazon Aurora 资源加密概览](#Overview.Encryption.Overview)
+ [加密 Amazon Aurora 数据库集群](#Overview.Encryption.Enabling)
+ [确定是否为数据库集群开启加密](#Overview.Encryption.Determining)
+ [Amazon Aurora 加密的可用性](#Overview.Encryption.Availability)
+ [传输中加密](#Overview.Encryption.InTransit)
+ [Amazon Aurora 加密的数据库集群的限制](#Overview.Encryption.Limitations)

## Amazon Aurora 资源加密概览
<a name="Overview.Encryption.Overview"></a>

Amazon Aurora 加密的数据库集群通过保护您的数据免受未经授权的访问来为基础存储提供额外一层数据保护。对于 2026 年 2 月 18 日当天或之后在 Amazon Aurora 中创建的所有新数据库集群，均使用行业标准 AES-256 加密进行静态加密。这种加密在后台自动进行，在不需要您采取任何操作的情况下保护您的数据。这样可以帮助减少在保护敏感数据时涉及的运营负担和复杂性。通过静态加密功能，您可以保护高度注重合规性且安全性至关重要的应用程序，防御意外和恶意威胁，同时满足监管要求。

Amazon Aurora 使用 AWS Key Management Service 密钥加密这些资源。AWS KMS 将安全、高度可用的硬件和软件结合起来，提供面向云端扩展的密钥管理系统。在创建新的数据库集群时，Amazon Aurora 默认情况下使用服务器端加密（SSE）和 [AWS 拥有的密钥](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#aws-owned-key)。不过，您可以根据自己的安全性和合规性需求，从三种加密类型中进行选择：
+ **AWS 拥有的密钥（SSE-RDS）**：完全由 AWS 控制的加密密钥，您无法查看或管理，Aurora 自动将其用于默认加密。
+ **AWS 托管式密钥（AMK）**：此密钥由 AWS 创建和管理，并且在您的账户中可见，但不可自定义。此密钥没有月度费用，但会收取 AWS KMS API 费用。
+ **客户自主管理型密钥（CMK）**：此密钥存储在您的账户中，由您创建、拥有和管理。您对 KMS 密钥拥有全部控制权（收取 AWS KMS 费用）。

AWS 托管式密钥是传统加密选项，仍然可用于向后兼容。默认情况下，Amazon Aurora 使用 AWS 拥有的密钥来加密您的数据，从而提供强大的安全保护，您无需支付额外费用或管理开销。对于大多数使用案例，我们建议使用默认 AWS 拥有的密钥来获得简化性和成本效益；如果您需要完全控制加密密钥，则建议使用客户自主管理型密钥（CMK）。有关密钥类型的更多信息，请参阅[客户自主管理型密钥和 AWS 托管式密钥](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-mgmt)。

**注意**  
**重要提示：**对于在 2026 年 2 月 18 日之前创建的源数据库实例或集群，如果您未选择进行加密，则从这些来源创建的快照、克隆和 Amazon Aurora 副本（只读实例）将保持未加密状态。但是，在 Amazon Aurora 集群之外执行的恢复操作和逻辑复制将会生成加密的实例。

 对于 Amazon Aurora 加密的数据库集群，所有数据库实例日志、备份和快照均会被加密。有关加密功能的可用性和限制的更多信息，请参阅 [Amazon Aurora 加密的可用性](#Overview.Encryption.Availability)和 [Amazon Aurora 加密的数据库集群的限制](#Overview.Encryption.Limitations)。

创建加密数据库集群时，您可以为 Amazon Aurora 选择客户自主管理型密钥或 AWS 托管式密钥来加密数据库集群。如果您没有为客户自主管理型密钥指定密钥标识符，则 Amazon Aurora 会对您的新数据库集群使用 AWS 托管式密钥。Amazon Aurora 将为您的 AWS 账户创建 Amazon Aurora 的 AWS 托管式密钥。您的 AWS 账户在每个 AWS 区域都有用于 Amazon Aurora 的不同 AWS 托管式密钥。

要管理用于加密和解密 Amazon Aurora 资源的客户自主管理型密钥，您可以使用 [AWS Key Management Service（AWS KMS）](https://docs.aws.amazon.com/kms/latest/developerguide/)。

利用 AWS KMS，您可创建客户自主管理型密钥，并定义策略来控制这些客户自主管理型密钥的使用方式。AWS KMS 支持 CloudTrail，因此，您可审核 KMS 密钥使用情况以验证客户自主管理型密钥是否使用得当。可以将客户托管密钥与 Amazon Aurora 和支持的 AWS 服务（例如 Amazon S3、Amazon EBS 和 Amazon Redshift）结合使用。有关与 AWS KMS 集成的服务的列表，请参阅 [AWS 服务集成](https://aws.amazon.com/kms/features/#AWS_Service_Integration)。关于使用 KMS 密钥的一些注意事项：
+ 创建加密的数据库实例后，您无法更改该实例使用的 KMS 密钥。请确保先确定您的 KMS 密钥要求，然后再创建加密的数据库实例。如果您需要更改数据库集群的加密密钥，请按照以下步骤执行操作：
  + 创建集群的手动快照。
  + 还原快照，在还原操作期间使用所需的 KMS 密钥启用加密。
+ 如果您还原未加密的快照并选择不加密，则创建的数据库集群将使用默认的静态加密（AWS 拥有的密钥）进行加密。
+ 如果快照已使用共享该快照的 AWS 托管式密钥 账户的 AWS 进行加密，则您无法共享该快照。
+ 数据库集群中的每个数据库实例共享使用相同 KMS 密钥加密的存储。

**重要**  
禁用 KMS 密钥后，Amazon Aurora 可能会失去对数据库集群的 KMS 密钥的访问权限。在这些情况下，加密的数据库集群会进入 `inaccessible-encryption-credentials-recoverable` 状态。数据库集群将保持此状态七天，在此期间实例停止运行。在此期间对该数据库集群进行的 API 调用可能不会成功。要恢复数据库集群，请启用 KMS 密钥并重新启动该数据库集群。您可以从 AWS 管理控制台、AWS CLI 或 RDS API 启用 KMS 密钥。使用 AWS CLI 命令 [start-db-cluster](https://docs.aws.amazon.com/cli/latest/reference/rds/start-db-cluster.html) 或 AWS 管理控制台重新启动数据库集群。  
`inaccessible-encryption-credentials-recoverable` 状态仅适用于可以停止的数据库集群。这种可恢复状态不适用于无法停止的实例，例如具有跨区域只读副本的集群。有关更多信息，请参阅 [停止和启动 Aurora 数据库集群的限制](aurora-cluster-stop-start.md#aurora-cluster-stop-limitations)。  
如果数据库集群未在七天内恢复，则该集群会进入终端 `inaccessible-encryption-credentials` 状态。在此状态下，数据库集群将无法再使用，您只能从备份还原数据库集群。我们强烈建议您始终启用备份，以防数据库中的数据丢失。  
在数据库集群创建期间，Aurora 会检查发出调用的主体是否有权访问 KMS 密钥，并从 KMS 密钥中生成授权，该授权将在数据库集群的整个生命周期内使用。撤消发出调用的主体对 KMS 密钥的访问权限，不会影响正在运行的数据库。在跨账户场景中使用 KMS 密钥时，例如将快照复制到其他账户，需要与其他账户共享 KMS 密钥。如果您从快照创建数据库集群但未指定不同的 KMS 密钥，则新集群将使用源账户中的 KMS 密钥。创建数据库集群后，撤消密钥访问权限不会影响集群。但是，禁用某个密钥会影响使用该密钥加密的所有数据库集群。为防止出现这种情况，请在快照复制操作期间指定不同的密钥。

有关 KMS 密钥的更多信息，请参阅《AWS Key Management Service 开发人员指南》**中的 [AWS KMS keys](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#kms_keys) 和[AWS KMS key 管理](Overview.Encryption.Keys.md)。

## 加密 Amazon Aurora 数据库集群
<a name="Overview.Encryption.Enabling"></a>

对于 2026 年 2 月 18 日当天或之后创建的所有新数据库集群，默认使用 AWS 拥有的密钥进行加密。

要使用 AWS 托管式密钥或客户自主管理型密钥加密新的数据库集群，请在控制台上选择相应选项。有关创建数据库集群的信息，请参阅[创建 Amazon Aurora 数据库集群](Aurora.CreateInstance.md)。

如果使用 [create-db-cluster](https://docs.aws.amazon.com/cli/latest/reference/rds/create-db-cluster.html) AWS CLI 命令创建加密的数据库集群，请设置 `--storage-encrypted` 参数。如果使用 [CreateDBCluster](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateDBCluster.html) API 操作，请将 `StorageEncrypted` 参数设置为 true。

创建加密的数据库集群后，您无法更改该数据库集群使用的 KMS 密钥。因此，请确保先确定您的 KMS 密钥要求，然后再创建加密的数据库集群。

如果使用 AWS CLI `create-db-cluster` 命令创建带有客户托管密钥的加密数据库集群，请将 `--kms-key-id` 参数设置为 KMS 密钥的任何密钥标识符。如果您使用 Amazon RDS API `CreateDBInstance` 操作，请将 `KmsKeyId` 参数设置为 KMS 密钥的任何密钥标识符。要在其他 AWS 账户中使用客户托管密钥，请指定密钥 ARN 或别名 ARN。

## 确定是否为数据库集群开启加密
<a name="Overview.Encryption.Determining"></a>

您可以使用 AWS 管理控制台、AWS CLI 或 RDS API 确定是否为数据库集群开启静态加密。

### 控制台
<a name="Overview.Encryption.Determining.CON"></a>

**要确定是否为数据库集群开启静态加密**

1. 登录AWS 管理控制台并通过以下网址打开 Amazon RDS 控制台：[https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/)。

1. 在导航窗格中，选择 **Databases (数据库)**。

1. 选择要检查的数据库集群的名称以显示其详细信息。

1. 选择 **Configuration**（配置）选项卡，然后检查 **Encryption**（加密）值。  
![\[检查数据库集群的静态加密\]](http://docs.aws.amazon.com/zh_cn/AmazonRDS/latest/AuroraUserGuide/images/encryption-aurora-instance.png)

### AWS CLI
<a name="Overview.Encryption.Determining.CLI"></a>

要使用 AWS CLI 确定是否已为数据库集群启用静态加密，请使用以下选项调用 [describe-db-clusters](https://docs.aws.amazon.com/cli/latest/reference/rds/describe-db-clusters.html) 命令：
+ `--db-cluster-identifier` – 数据库集群的名称。

下面的示例使用查询就 `mydb` 数据库集群的静态加密返回 `TRUE` 或 `FALSE`。

**Example**  

```
1. aws rds describe-db-clusters --db-cluster-identifier mydb --query "*[].{StorageEncrypted:StorageEncrypted}" --output text
```

### RDS API
<a name="Overview.Encryption.Determining.API"></a>

要使用 Amazon RDS API 确定是否已为数据库集群启用静态加密，请使用以下参数调用 [DescribeDBClusters](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DescribeDBClusters.html) 操作：
+ `DBClusterIdentifier` – 数据库集群的名称。

## Amazon Aurora 加密的可用性
<a name="Overview.Encryption.Availability"></a>

Amazon Aurora 加密当前可用于所有数据库引擎和存储类型。

**注意**  
Amazon Aurora 加密不适用于 db.t2.micro 数据库实例类。

## 传输中加密
<a name="Overview.Encryption.InTransit"></a>

**物理层加密**  
所有在 AWS 全球网络上跨 AWS 区域流动的数据在离开受 AWS 保护的设施之前，都会在物理层自动加密。可用区之间的所有流量均已加密。其它加密层（包括本节中列出的加密层）可能会提供额外保护。

**Amazon VPC 对等连接和 Transit Gateway 跨区域对等连接提供的加密**  
使用 Amazon VPC 和 Transit Gateway 对等连接的所有跨区域流量在退出区域时都会自动批量加密。所有流量在离开受 AWS 保护的设施之前，均会在物理层自动提供额外一层加密。

**实例之间的加密**  
AWS 在所有类型的数据库实例之间提供安全的私有连接。此外，某些实例类型使用底层 Nitro 系统硬件的卸载功能，自动加密实例之间的传输中流量。此加密使用关联数据的身份验证加密（AEAD）算法，采用 256 位加密。这对网络性能没有影响。要在实例之间支持这种额外的传输中流量加密，必须满足以下要求：  
+ 使用以下实例类型：
  + **通用型：**M6i、M6id、M6in、M6idn、M7g
  + **内存优化型：**R6i、R6id、R6in、R6idn、R7g、X2idn、X2iedn、X2iezn
+ 这些实例位于同一 AWS 区域。
+ 这些实例位于相同 VPC 或对等的 VPC 中，并且流量不会通过虚拟网络设备或服务（如负载均衡器或中转网关）传输。

## Amazon Aurora 加密的数据库集群的限制
<a name="Overview.Encryption.Limitations"></a>

Amazon Aurora 加密的数据库集群存在以下限制：
+ 您无法在加密的数据库集群上关闭加密。
+ 如果您有一个现有的未加密集群，则从该集群创建的所有快照也将是未加密的。要从未加密的集群创建加密快照，您必须复制该快照并在复制操作期间指定客户自主管理型密钥。要从未加密快照创建加密快照，您必须指定客户自主管理型密钥。
+ 您无法创建未加密数据库的加密快照。
+ 加密数据库集群的快照必须使用与数据库集群相同的 KMS 密钥进行加密。
+ 您无法将未加密的数据库集群转换为加密的数据库集群。但是，您可以将未加密的快照还原为加密的 Aurora 数据库集群。为此，请在从未加密的快照还原时指定 KMS 密钥。
+ 如果您有一个现有的未加密集群，从该集群创建的任何 Amazon Aurora 副本（只读实例）也将是未加密的。要从未加密的集群创建加密集群，您需要还原数据库集群。默认情况下，还原后的集群将在执行还原操作后进行加密。
+ 要将已加密快照从一个 AWS 区域复制到另一个区域，您必须指定目标 AWS 区域的 KMS 密钥。这是因为 KMS 密钥特定于在其中创建它们的 AWS 区域。

  源快照在复制过程中保持加密状态。Amazon Aurora 使用信封加密在复制过程中保护数据。有关信封加密的更多信息，请参阅*AWS Key Management Service开发人员指南*中的[信封加密](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#enveloping)。
+ 您无法对加密数据库集群取消加密。但是，您可以从加密的数据库集群中导出数据，然后将数据导入未加密的数据库集群。

# AWS KMS key 管理
<a name="Overview.Encryption.Keys"></a>

 Amazon Aurora 自动与 [AWS Key Management Service（AWS KMS）](https://docs.aws.amazon.com/kms/latest/developerguide/)集成以进行密钥管理。Amazon Aurora 使用信封加密。有关信封加密的更多信息，请参阅 *AWS Key Management Service 开发人员指南*中的[信封加密](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#enveloping)。

您可以使用两种类型的 AWS KMS 密钥来加密数据库集群。
+ 要完全控制 KMS 密钥，您必须创建*客户托管密钥*。有关客户托管密钥的更多信息，请参阅 *AWS Key Management Service 开发人员指南*中的[客户托管密钥](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#customer-cmk)。
+  *AWS 托管式密钥* 是由与 AWS KMS 集成的 AWS 服务代表您在账户中创建、管理和使用的 KMS 密钥。默认情况下，RDS AWS 托管式密钥（`aws/rds`）用于加密。您无法管理、轮换或删除 RDS AWS 托管式密钥。有关 AWS 托管式密钥 的更多信息，请参阅《AWS Key Management Service 开发人员指南》**中的 [AWS 托管式密钥](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#aws-managed-cmk)。

要管理用于 Amazon Aurora 加密数据库集群的 KMS 密钥，您可以使用 [AWS KMS 控制台](https://console.aws.amazon.com/kms)中的 [AWS Key Management Service（AWS KMS）](https://docs.aws.amazon.com/kms/latest/developerguide/)、AWS CLI 或 AWS KMS API。要查看利用 AWS 托管式或客户托管密钥执行的每个操作的审计日志，请使用 [AWS CloudTrail](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/)。有关密钥轮换的更多信息，请参阅[轮换 AWS KMS 密钥](https://docs.aws.amazon.com/kms/latest/developerguide/rotate-keys.html)。

## 授权使用客户托管密钥
<a name="Overview.Encryption.Keys.Authorizing"></a>

Aurora 在加密操作中使用客户自主管理型密钥时，其代表创建或更改 Aurora 资源的用户执行操作。

要使用客户自主管理型密钥创建 Aurora 资源，用户必须具有对客户自主管理型密钥调用以下操作的权限：
+  `kms:CreateGrant` 
+  `kms:DescribeKey` 

您可以在密钥策略中指定这些所需权限，或者在密钥策略允许的情况下在 IAM 策略中指定这些权限。

**重要**  
当您在 Amazon RDS 等托管式服务的 AWS KMS 密钥策略中对所有资源（\$1）使用显式拒绝语句时，您必须指定一个条件来支持拥有资源的账户。如果没有此条件，操作可能会失败，即使拒绝规则中包含针对您的 IAM 用户的例外情况也是如此。

**提示**  
为遵循最小特权原则，请不要允许对 `kms:CreateGrant` 拥有完全访问权限。而是仅当 AWS 服务代表用户创建授权时，才使用 [kms:ViaService 条件密钥](https://docs.aws.amazon.com/kms/latest/developerguide/policy-conditions.html#conditions-kms-via-service)来支持用户对 KMS 密钥创建授权。

您可以通过各种方式使 IAM 策略更严格。例如，如果您要支持将客户自主管理型密钥仅用于源自 Aurora 的请求，请将 [kms:ViaService 条件密钥](https://docs.aws.amazon.com/kms/latest/developerguide/policy-conditions.html#conditions-kms-via-service)与 `rds.<region>.amazonaws.com` 值结合使用。此外，您可以使用[Amazon RDS 加密上下文](#Overview.Encryption.Keys.encryptioncontext)中的密钥或值作为使用客户托管密钥进行加密的条件。

有关更多信息，请参阅《AWS Key Management Service 开发人员指南》**中的[允许其他账户中的用户使用 KMS 密钥](https://docs.aws.amazon.com/kms/latest/developerguide/key-policy-modifying-external-accounts.html)和 [AWS KMS 中的密钥策略](https://docs.aws.amazon.com/kms/latest/developerguide/key-policies)。

## Amazon RDS 加密上下文
<a name="Overview.Encryption.Keys.encryptioncontext"></a>

当 Aurora 使用您的 KMS 密钥时，或者当 Amazon EBS 代表 Aurora 使用 KMS 密钥时，服务会指定[加密上下文](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#encrypt_context)。加密上下文是 AWS KMS 用于确保数据完整性而使用的[额外的身份验证数据](https://docs.aws.amazon.com/crypto/latest/userguide/cryptography-concepts.html#term-aad) (AAD)。在为加密操作指定加密上下文时，该服务必须为解密操作指定同一加密上下文。否则，解密将失败。加密上下文还将写至您的 [AWS CloudTrail](https://aws.amazon.com/cloudtrail/) 日志中，以帮助您了解为什么使用给定的 KMS 密钥。您的 CloudTrail 日志可能包含多个描述 KMS 密钥使用情况的条目，但每个日志条目中的加密上下文可以帮助您确定该特定使用的原因。

至少，Aurora 始终将数据库集群 ID 用于加密上下文，如以下 JSON 格式的示例所示：

```
{ "aws:rds:dbc-id": "cluster-CQYSMDPBRZ7BPMH7Y3RTDG5QY" }
```

此加密上下文可以帮助您确定使用您的 KMS 密钥的数据库集群。

当您的 KMS 密钥用于特定的数据库集群和特定的 Amazon EBS 卷时，数据库集群 ID 和 Amazon EBS 卷 ID 将用于加密上下文，如以下 JSON 格式的示例所示：

```
{
  "aws:rds:dbc-id": "cluster-BRG7VYS3SVIFQW7234EJQOM5RQ",
  "aws:ebs:id": "vol-ad8c6542"
}
```

# 使用 SSL/TLS 加密与数据库集群的连接
<a name="UsingWithRDS.SSL"></a>

您可以使用应用程序中的安全套接字层 (SSL) 或传输层安全 (TLS) 来加密与运行 Aurora MySQL 或 Aurora PostgreSQL 的数据库集群的连接。

SSL/TLS 连接对在客户端和数据库集群之间移动的数据进行加密，从而提供一层额外的安全性。（可选）您的 SSL/TLS 连接可以通过验证安装在数据库上的服务器证书来执行服务器身份验证。要请求服务器身份验证，请遵循以下一般流程：

1. 为数据库选择对**数据库服务器证书**进行签名的**证书颁发机构（CA）**。有关证书颁发机构的更多信息，请参阅[证书颁发机构](#UsingWithRDS.SSL.RegionCertificateAuthorities)。

1. 下载证书包，以便在连接到数据库时使用。要下载证书捆绑包，请参阅。。[按 AWS 区域列出的证书捆绑包](#UsingWithRDS.SSL.CertificatesAllRegions)。
**注意**  
只能使用 SSL/TLS 连接下载所有证书。

1. 使用数据库引擎用于实现 SSL/TLS 连接的过程连接到数据库。每个数据库引擎都有自己的用于实施 SSL/TLS 的过程。要了解如何为您的数据库实施 SSL/TLS，请使用对应于您的数据库引擎的链接：
   +  [使用 Amazon Aurora MySQL 实现高安全性](AuroraMySQL.Security.md) 
   +  [使用 Amazon Aurora PostgreSQL 实现高安全性](AuroraPostgreSQL.Security.md) 

## 证书颁发机构
<a name="UsingWithRDS.SSL.RegionCertificateAuthorities"></a>

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

![\[证书颁发机构概述\]](http://docs.aws.amazon.com/zh_cn/AmazonRDS/latest/AuroraUserGuide/images/certificate-authority-overview.png)


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


****  

| 证书颁发机构（CA） | 说明 | 公用名 (CN) | 
| --- | --- | --- | 
|  rds-ca-rsa2048-g1  |  在大多数 AWS 区域中，使用具有 RSA 2048 私有密钥算法和 SHA256 签名算法的证书颁发机构。 在 AWS GovCloud (US) Regions中，此 CA 使用具有 RSA 2048 私有密钥算法和 SHA384 签名算法的证书颁发机构。 此 CA 支持服务器证书自动轮换。  | Amazon RDS region-identifier Root CA RSA2048 G1 | 
|  rds-ca-rsa4096-g1  |  使用具有 RSA 4096 私有密钥算法和 SHA384 签名算法的证书颁发机构。此 CA 支持服务器证书自动轮换。  | Amazon RDS region-identifier Root CA RSA4096 G1 | 
|  rds-ca-ecc384-g1  |  使用具有 ECC 384 私有密钥算法和 SHA384 签名算法的证书颁发机构。此 CA 支持服务器证书自动轮换。  | Amazon RDS region-identifier Root CA ECC384 G1 | 

**注意**  
如果您使用的是 AWS CLI，则可以使用 [describe-certificates](https://docs.aws.amazon.com/cli/latest/reference/rds/describe-certificates.html) 查看上面列出的证书颁发机构的有效性。

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

### 为数据库设置 CA
<a name="UsingWithRDS.SSL.RegionCertificateAuthorities.Selection"></a>

您可以在执行以下任务时为数据库设置 CA：
+ 创建 Aurora 数据库集群 - 当您使用 AWS CLI 或 RDS API 在数据库集群中创建第一个数据库实例时，可以为 Aurora 集群中的数据库实例设置 CA。目前，在使用 RDS 控制台创建数据库集群时，无法为数据库集群中的数据库实例设置 CA。有关说明，请参阅 [创建 Amazon Aurora 数据库集群](Aurora.CreateInstance.md)。
+ 修改数据库实例 - 您可以通过修改数据库集群中的数据库实例为其设置 CA。有关说明，请参阅 [修改数据库集群中的数据库实例](Aurora.Modifying.md#Aurora.Modifying.Instance)。

**注意**  
 默认 CA 设置为 rds-ca-rsa2048-g1。您可以使用 [modify-certificates](https://docs.aws.amazon.com/cli/latest/reference/rds/modify-certificates.html) 命令为您的 AWS 账户覆盖默认 CA。

可用的 CA 取决于数据库引擎和数据库引擎版本。使用 AWS 管理控制台时，您可以使用 **Certificate authority**（证书颁发机构）设置选择 CA，如下图所示。

![\[证书颁发机构选项\]](http://docs.aws.amazon.com/zh_cn/AmazonRDS/latest/AuroraUserGuide/images/certificate-authority.png)


控制台仅显示可用于数据库引擎和数据库引擎版本的 CA。如果您使用的是 AWS CLI，则可以使用 [create-db-instance](https://docs.aws.amazon.com/cli/latest/reference/rds/create-db-instance.html) 或 [modify-db-instance](https://docs.aws.amazon.com/cli/latest/reference/rds/modify-db-instance.html) 命令为数据库实例设置 CA。

如果您使用的是 AWS CLI，则可以使用 [describe-certificates](https://docs.aws.amazon.com/cli/latest/reference/rds/describe-certificates.html) 命令查看您账户的可用 CA。此命令还在输出的 `ValidTill` 中显示每个 CA 的到期日期。您可以使用 [describe-db-engine-versions](https://docs.aws.amazon.com/cli/latest/reference/rds/describe-db-engine-versions.html) 命令找到适用于特定数据库引擎和数据库引擎版本的 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-rsa2048-g1",
                "rds-ca-ecc384-g1",
                "rds-ca-rsa4096-g1"
            ]
        }
    ]
}
```

### 数据库服务器证书有效期
<a name="UsingWithRDS.SSL.RegionCertificateAuthorities.DBServerCert"></a>

数据库服务器证书的有效期取决于数据库引擎和数据库引擎版本。如果数据库引擎版本支持在不重启的情况下轮换证书，则数据库服务器证书的有效期为 1 年。否则，有效期为 3 年。

有关数据库服务器证书轮换的更多信息，请参阅[自动服务器证书轮换](UsingWithRDS.SSL-certificate-rotation.md#UsingWithRDS.SSL-certificate-rotation-server-cert-rotation)。

### 查看数据库实例的 CA
<a name="UsingWithRDS.SSL.RegionCertificateAuthorities.Viewing"></a>

您可以通过查看控制台中的**连接性和安全性**选项卡来查看有关数据库的 CA 的详细信息，如下图所示。

![\[证书颁发机构详细信息\]](http://docs.aws.amazon.com/zh_cn/AmazonRDS/latest/AuroraUserGuide/images/certificate-authority-details.png)


如果您使用的是 AWS CLI，您可以使用 [describe-db-instances](https://docs.aws.amazon.com/cli/latest/reference/rds/describe-db-instances.html) 命令，查看有关数据库实例的 CA 的详细信息。

## 下载 Aurora 的证书捆绑包
<a name="UsingWithRDS.SSL.CertificatesDownload"></a>

当您使用 SSL 或 TLS 连接到数据库时，数据库实例需要来自 Amazon RDS 的信任证书。在下表中选择相应的链接，来下载与托管数据库的 AWS 区域相对应的捆绑包。

### 按 AWS 区域列出的证书捆绑包
<a name="UsingWithRDS.SSL.CertificatesAllRegions"></a>

所有 AWS 区域和 GovCloud（美国）区域的证书捆绑包均包含以下根 CA 证书：
+  `rds-ca-rsa2048-g1` 
+  `rds-ca-rsa4096-g1` 
+  `rds-ca-ecc384-g1` 

`rds-ca-rsa4096-g1` 和 `rds-ca-ecc384-g1` 证书在以下区域不可用：
+ 亚太地区（孟买）
+ 亚太地区（墨尔本）
+ 加拿大西部（卡尔加里）
+ 欧洲（苏黎世）
+ 欧洲（西班牙）
+ 以色列（特拉维夫）

您的应用程序信任存储只需要注册根 CA 证书。请勿将中间 CA 证书注册到您的信任存储区，因为当 RDS 自动轮换您的数据库服务器证书时，这可能会导致连接问题。

**注意**  
Amazon RDS 代理和 Aurora Serverless v1 使用来自 AWS Certificate Manager（ACM）的证书。如果您使用的是 RDS 代理，则无需下载 Amazon RDS 证书或更新使用 RDS 代理连接的应用程序。有关更多信息，请参阅 [将 TLS/SSL 与 RDS 代理结合使用](rds-proxy.howitworks.md#rds-proxy-security.tls)。  
如果您使用的是 Aurora Serverless v1，则不需要下载 Amazon RDS 证书。有关更多信息，请参阅 [将 TLS/SSL 与 Aurora Serverless v1 结合使用](aurora-serverless.md#aurora-serverless.tls)。

要下载 AWS 区域的证书捆绑包，请在下表中选择与托管数据库的 AWS 区域相对应的链接。


|  **AWS 区域**  |  **证书捆绑包 (PEM)**  |  **证书捆绑包 (PKCS7)**  | 
| --- | --- | --- | 
| 任何商业 AWS 区域 |  [global-bundle.pem](https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem)  |  [global-bundle.p7b](https://truststore.pki.rds.amazonaws.com/global/global-bundle.p7b)  | 
| 美国东部（弗吉尼亚州北部） |  [us-east-1-bundle.pem](https://truststore.pki.rds.amazonaws.com/us-east-1/us-east-1-bundle.pem)  |  [us-east-1-bundle.p7b](https://truststore.pki.rds.amazonaws.com/us-east-1/us-east-1-bundle.p7b)  | 
| US East (Ohio) |  [us-east-2-bundle.pem](https://truststore.pki.rds.amazonaws.com/us-east-2/us-east-2-bundle.pem)  |  [us-east-2-bundle.p7b](https://truststore.pki.rds.amazonaws.com/us-east-2/us-east-2-bundle.p7b)  | 
| 美国西部（加利福尼亚北部） |  [us-west-1-bundle.pem](https://truststore.pki.rds.amazonaws.com/us-west-1/us-west-1-bundle.pem)  |  [us-west-1-bundle.p7b](https://truststore.pki.rds.amazonaws.com/us-west-1/us-west-1-bundle.p7b)  | 
| 美国西部（俄勒冈州） |  [us-west-2-bundle.pem](https://truststore.pki.rds.amazonaws.com/us-west-2/us-west-2-bundle.pem)  |  [us-west-2-bundle.p7b](https://truststore.pki.rds.amazonaws.com/us-west-2/us-west-2-bundle.p7b)  | 
| Africa (Cape Town) |  [af-south-1-bundle.pem](https://truststore.pki.rds.amazonaws.com/af-south-1/af-south-1-bundle.pem)  |  [af-south-1-bundle.p7b](https://truststore.pki.rds.amazonaws.com/af-south-1/af-south-1-bundle.p7b)  | 
| Asia Pacific (Hong Kong) |  [ap-east-1-bundle.pem](https://truststore.pki.rds.amazonaws.com/ap-east-1/ap-east-1-bundle.pem)  |  [ap-east-1-bundle.p7b](https://truststore.pki.rds.amazonaws.com/ap-east-1/ap-east-1-bundle.p7b)  | 
| 亚太地区（海得拉巴） |  [ap-south-2-bundle.pem](https://truststore.pki.rds.amazonaws.com/ap-south-2/ap-south-2-bundle.pem)  |  [ap-south-2-bundle.p7b](https://truststore.pki.rds.amazonaws.com/ap-south-2/ap-south-2-bundle.p7b)  | 
| 亚太地区（雅加达） |  [ap-southeast-3-bundle.pem](https://truststore.pki.rds.amazonaws.com/ap-southeast-3/ap-southeast-3-bundle.pem)  |  [ap-southeast-3-bundle.p7b](https://truststore.pki.rds.amazonaws.com/ap-southeast-3/ap-southeast-3-bundle.p7b)  | 
| 亚太地区（马来西亚） |  [ap-southeast-5-bundle.pem](https://truststore.pki.rds.amazonaws.com/ap-southeast-5/ap-southeast-5-bundle.pem)  |  [ap-southeast-5-bundle.p7b](https://truststore.pki.rds.amazonaws.com/ap-southeast-5/ap-southeast-5-bundle.p7b)  | 
| 亚太地区（墨尔本） |  [ap-southeast-4-bundle.pem](https://truststore.pki.rds.amazonaws.com/ap-southeast-4/ap-southeast-4-bundle.pem)  |  [ap-southeast-4-bundle.p7b](https://truststore.pki.rds.amazonaws.com/ap-southeast-4/ap-southeast-4-bundle.p7b)  | 
| 亚太地区（孟买） |  [ap-south-1-bundle.pem](https://truststore.pki.rds.amazonaws.com/ap-south-1/ap-south-1-bundle.pem)  |  [ap-south-1-bundle.p7b](https://truststore.pki.rds.amazonaws.com/ap-south-1/ap-south-1-bundle.p7b)  | 
| 亚太地区（大阪） |  [ap-northeast-3-bundle.pem](https://truststore.pki.rds.amazonaws.com/ap-northeast-3/ap-northeast-3-bundle.pem)  |  [ap-northeast-3-bundle.p7b](https://truststore.pki.rds.amazonaws.com/ap-northeast-3/ap-northeast-3-bundle.p7b)  | 
| 亚太地区（泰国） |  [ap-southeast-7-bundle.pem](https://truststore.pki.rds.amazonaws.com/ap-southeast-7/ap-southeast-7-bundle.pem)  |  [ap-southeast-7-bundle.p7b](https://truststore.pki.rds.amazonaws.com/ap-southeast-7/ap-southeast-7-bundle.p7b)  | 
| 亚太区域（东京） |  [ap-northeast-1-bundle.pem](https://truststore.pki.rds.amazonaws.com/ap-northeast-1/ap-northeast-1-bundle.pem)  |  [ap-northeast-1-bundle.p7b](https://truststore.pki.rds.amazonaws.com/ap-northeast-1/ap-northeast-1-bundle.p7b)  | 
| 亚太地区（首尔） |  [ap-northeast-2-bundle.pem](https://truststore.pki.rds.amazonaws.com/ap-northeast-2/ap-northeast-2-bundle.pem)  |  [ap-northeast-2-bundle.p7b](https://truststore.pki.rds.amazonaws.com/ap-northeast-2/ap-northeast-2-bundle.p7b)  | 
| 亚太地区（新加坡） |  [ap-southeast-1-bundle.pem](https://truststore.pki.rds.amazonaws.com/ap-southeast-1/ap-southeast-1-bundle.pem)  |  [ap-southeast-1-bundle.p7b](https://truststore.pki.rds.amazonaws.com/ap-southeast-1/ap-southeast-1-bundle.p7b)  | 
| 亚太地区（悉尼） |  [ap-southeast-2-bundle.pem](https://truststore.pki.rds.amazonaws.com/ap-southeast-2/ap-southeast-2-bundle.pem)  |  [ap-southeast-2-bundle.p7b](https://truststore.pki.rds.amazonaws.com/ap-southeast-2/ap-southeast-2-bundle.p7b)  | 
| 加拿大（中部） |  [ca-central-1-bundle.pem](https://truststore.pki.rds.amazonaws.com/ca-central-1/ca-central-1-bundle.pem)  |  [ca-central-1-bundle.p7b](https://truststore.pki.rds.amazonaws.com/ca-central-1/ca-central-1-bundle.p7b)  | 
| 加拿大西部（卡尔加里） |  [ca-west-1-bundle.pem](https://truststore.pki.rds.amazonaws.com/ca-west-1/ca-west-1-bundle.pem)  |  [ca-west-1-bundle.p7b](https://truststore.pki.rds.amazonaws.com/ca-west-1/ca-west-1-bundle.p7b)  | 
| 欧洲地区（法兰克福） |  [eu-central-1-bundle.pem](https://truststore.pki.rds.amazonaws.com/eu-central-1/eu-central-1-bundle.pem)  |  [eu-central-1-bundle.p7b](https://truststore.pki.rds.amazonaws.com/eu-central-1/eu-central-1-bundle.p7b)  | 
| 欧洲地区（爱尔兰） |  [eu-west-1-bundle.pem](https://truststore.pki.rds.amazonaws.com/eu-west-1/eu-west-1-bundle.pem)  |  [eu-west-1-bundle.p7b](https://truststore.pki.rds.amazonaws.com/eu-west-1/eu-west-1-bundle.p7b)  | 
| 欧洲地区（伦敦） |  [eu-west-2-bundle.pem](https://truststore.pki.rds.amazonaws.com/eu-west-2/eu-west-2-bundle.pem)  |  [eu-west-2-bundle.p7b](https://truststore.pki.rds.amazonaws.com/eu-west-2/eu-west-2-bundle.p7b)  | 
| 欧洲地区（米兰） |  [eu-south-1-bundle.pem](https://truststore.pki.rds.amazonaws.com/eu-south-1/eu-south-1-bundle.pem)  |  [eu-south-1-bundle.p7b](https://truststore.pki.rds.amazonaws.com/eu-south-1/eu-south-1-bundle.p7b)  | 
| 欧洲地区（巴黎） |  [eu-west-3-bundle.pem](https://truststore.pki.rds.amazonaws.com/eu-west-3/eu-west-3-bundle.pem)  |  [eu-west-3-bundle.p7b](https://truststore.pki.rds.amazonaws.com/eu-west-3/eu-west-3-bundle.p7b)  | 
| 欧洲（西班牙） |  [eu-south-2-bundle.pem](https://truststore.pki.rds.amazonaws.com/eu-south-2/eu-south-2-bundle.pem)  |  [eu-south-2-bundle.p7b](https://truststore.pki.rds.amazonaws.com/eu-south-2/eu-south-2-bundle.p7b)  | 
| 欧洲地区（斯德哥尔摩） |  [eu-north-1-bundle.pem](https://truststore.pki.rds.amazonaws.com/eu-north-1/eu-north-1-bundle.pem)  |  [eu-north-1-bundle.p7b](https://truststore.pki.rds.amazonaws.com/eu-north-1/eu-north-1-bundle.p7b)  | 
| 欧洲（苏黎世） |  [eu-central-2-bundle.pem](https://truststore.pki.rds.amazonaws.com/eu-central-2/eu-central-2-bundle.pem)  |  [eu-central-2-bundle.p7b](https://truststore.pki.rds.amazonaws.com/eu-central-2/eu-central-2-bundle.p7b)  | 
| 以色列（特拉维夫） |  [il-central-1-bundle.pem](https://truststore.pki.rds.amazonaws.com/il-central-1/il-central-1-bundle.pem)  |  [il-central-1-bundle.p7b](https://truststore.pki.rds.amazonaws.com/il-central-1/il-central-1-bundle.p7b)  | 
| 墨西哥（中部） |  [mx-central-1-bundle.pem](https://truststore.pki.rds.amazonaws.com/mx-central-1/mx-central-1-bundle.pem)  |  [mx-central-1-bundle.p7b](https://truststore.pki.rds.amazonaws.com/mx-central-1/mx-central-1-bundle.p7b)  | 
| 中东（巴林） |  [me-south-1-bundle.pem](https://truststore.pki.rds.amazonaws.com/me-south-1/me-south-1-bundle.pem)  |  [me-south-1-bundle.p7b](https://truststore.pki.rds.amazonaws.com/me-south-1/me-south-1-bundle.p7b)  | 
| 中东（阿联酋） |  [me-central-1-bundle.pem](https://truststore.pki.rds.amazonaws.com/me-central-1/me-central-1-bundle.pem)  |  [me-central-1-bundle.p7b](https://truststore.pki.rds.amazonaws.com/me-central-1/me-central-1-bundle.p7b)  | 
| 南美洲（圣保罗） |  [sa-east-1-bundle.pem](https://truststore.pki.rds.amazonaws.com/sa-east-1/sa-east-1-bundle.pem)  |  [sa-east-1-bundle.p7b](https://truststore.pki.rds.amazonaws.com/sa-east-1/sa-east-1-bundle.p7b)  | 
| 任何 AWS GovCloud (US) Region |  [global-bundle.pem](https://truststore.pki.us-gov-west-1.rds.amazonaws.com/global/global-bundle.pem)  |  [global-bundle.p7b](https://truststore.pki.us-gov-west-1.rds.amazonaws.com/global/global-bundle.p7b)  | 
| AWS GovCloud（美国东部） |  [us-gov-east-1-bundle.pem](https://truststore.pki.us-gov-west-1.rds.amazonaws.com/us-gov-east-1/us-gov-east-1-bundle.pem)  |  [us-gov-east-1-bundle.p7b](https://truststore.pki.us-gov-west-1.rds.amazonaws.com/us-gov-east-1/us-gov-east-1-bundle.p7b)  | 
| AWS GovCloud（美国西部） |  [us-gov-west-1-bundle.pem](https://truststore.pki.us-gov-west-1.rds.amazonaws.com/us-gov-west-1/us-gov-west-1-bundle.pem)  |  [us-gov-west-1-bundle.p7b](https://truststore.pki.us-gov-west-1.rds.amazonaws.com/us-gov-west-1/us-gov-west-1-bundle.p7b)  | 

### 查看 CA 证书的内容
<a name="UsingWithRDS.SSL.CertificatesDownload.viewing"></a>

要检查您的 CA 证书包的内容，请使用以下命令：

```
keytool -printcert -v -file global-bundle.pem
```

# 轮换 SSL/TLS 证书
<a name="UsingWithRDS.SSL-certificate-rotation"></a>

Amazon RDS 证书颁发机构证书 rds-ca-2019 于 2024 年 8 月到期。如果您使用或计划使用带有证书验证的安全套接字层（SSL）或传输层安全性协议（TLS）来连接您的 RDS 数据库实例，则考虑使用新的 CA 证书之一：rds-ca-rsa2048-g1、rds-ca-rsa4096-g1 或 rds-ca-ecc384-g1。如果您当前未将 SSL/TLS 用于证书验证，则可能仍有过期的 CA 证书，如果您计划为证书验证使用 SSL/TLS 连接到 RDS 数据库，则必须将它们更新为新的 CA 证书。

Amazon RDS 提供新 CA 证书作为AWS最佳安全实践。有关新证书和受支持的 AWS 区域的信息，请参阅[使用 SSL/TLS 加密与数据库集群的连接](UsingWithRDS.SSL.md)。

要更新数据库的 CA 证书，请使用以下方法：
+  [通过修改数据库实例来更新 CA 证书](#UsingWithRDS.SSL-certificate-rotation-updating) 
+  [通过应用维护来更新 CA 证书](#UsingWithRDS.SSL-certificate-rotation-maintenance-update) 

更新数据库实例来使用新的 CA 证书之前，请确保更新连接到 RDS 数据库的客户端或应用程序。

## 轮换证书的注意事项
<a name="UsingWithRDS.SSL-certificate-rotation-considerations"></a>

在轮换证书之前，请考虑以下情况：
+ Amazon RDS 代理和 Aurora Serverless v1 使用来自 AWS Certificate Manager（ACM）的证书。如果您使用的是 RDS 代理，当您轮换 SSL/TLS 证书时，您不需要更新使用 RDS 代理连接的应用程序。有关更多信息，请参阅 [将 TLS/SSL 与 RDS 代理结合使用](rds-proxy.howitworks.md#rds-proxy-security.tls)。
+ 如果您使用的是 Aurora Serverless v1，则不需要下载 Amazon RDS 证书。有关更多信息，请参阅 [将 TLS/SSL 与 Aurora Serverless v1 结合使用](aurora-serverless.md#aurora-serverless.tls)。
+ 如果您将 Go 版本 1.15 应用程序与在 2020 年 7 月 28 日之前创建或更新到 rds-ca-2019 证书的数据库实例一起使用，则必须再次更新证书。将证书更新为 rds-ca-rsa2048-g1、rds-ca-rsa4096-g1 或 rds-ca-ecc384-g1，具体取决于您的引擎。

  使用新的 CA 证书标识符，。您可以使用 `describe-db-engine-versions` 命令找到适用于特定数据库引擎和数据库引擎版本的 CA。

  如果您在 2020 年 7 月 28 日之后创建了数据库或更新了其证书，则无需执行任何操作。有关更多信息，请参阅 [Go GitHub 问题 \$139568](https://github.com/golang/go/issues/39568)。

## 通过修改数据库实例来更新 CA 证书
<a name="UsingWithRDS.SSL-certificate-rotation-updating"></a>

以下示例将您的 CA 证书从 *rds-ca-2019* 更新为 *rds-ca-rsa2048-g1*。您可以选择其他证书。有关更多信息，请参阅 [证书颁发机构](UsingWithRDS.SSL.md#UsingWithRDS.SSL.RegionCertificateAuthorities)。

更新您的应用程序信任存储，以减少任何与更新 CA 证书相关的停机时间。有关与 CA 证书轮换相关的重启的更多信息，请参阅[自动服务器证书轮换](#UsingWithRDS.SSL-certificate-rotation-server-cert-rotation)。

**通过修改数据库实例来更新 CA 证书**

1. 下载新的 SSL/TLS 证书，如[使用 SSL/TLS 加密与数据库集群的连接](UsingWithRDS.SSL.md)中所述。

1. 更新应用程序以使用新的 SSL/TLS 证书。

   更新应用程序以使用新 SSL/TLS 证书的方法取决于特定的应用程序。请与应用程序开发人员一起更新应用程序的 SSL/TLS 证书。

   有关检查 SSL/TLS 连接和更新每个数据库引擎的应用程序的信息，请参阅以下主题：
   +  [使用新的 TLS 证书更新应用程序，以连接到 Aurora MySQL 数据库集群](ssl-certificate-rotation-aurora-mysql.md) 
   +  [使用新 SSL/TLS 证书更新应用程序，以连接到 Aurora PostgreSQL 数据库集群](ssl-certificate-rotation-aurora-postgresql.md) 

   有关更新 Linux 操作系统信任存储的示例脚本，请参阅[将证书导入信任存储的示例脚本](#UsingWithRDS.SSL-certificate-rotation-sample-script)。
**注意**  
证书捆绑包包含新旧 CA 证书，因此您可以安全地升级应用程序并在转换期间保持连接。如果您正在使用 AWS Database Migration Service 将数据库迁移到数据库集群，我们建议您使用证书捆绑包来确保迁移期间的连接性。

1. 修改数据库实例，以便将 CA 从 **rds-ca-2019** 更改为 **rds-ca-rsa2048-g1**。要检查您的数据库是否需要重启才能更新 CA 证书，请使用 [describe-db-engine-versions](https://docs.aws.amazon.com/cli/latest/reference/rds/describe-db-engine-versions.html) 命令并检查 `SupportsCertificateRotationWithoutRestart` 标志。
**注意**  
修改后重启您的 Babelfish 集群以更新 CA 证书。
**重要**  
如果您在证书到期后遇到连接问题，请通过在控制台中指定 **Apply immediately (立即应用)** 或者 使用 `--apply-immediately` 指定 AWS CLI 选项来使用“立即应用”选项。默认情况下，此操作安排在您的下个维护时段运行。  
要为与默认 RDS CA 不同的集群 CA 设置覆盖，请使用 [modify-certificates](https://docs.aws.amazon.com/cli/latest/reference/rds/modify-certificates.html) CLI 命令。

您可以使用 AWS 管理控制台或 AWS CLI，对于数据库实例，将 CA 证书从 **rds-ca-2019** 更改为 **rds-ca-rsa2048-g1**。

------
#### [ Console ]

1. 登录 AWS 管理控制台 并通过以下网址打开 Amazon RDS 控制台：[https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/)。

1. 在导航窗格中，选择**数据库**，然后选择要修改的数据库实例。

1. 选择 **Modify**(修改)。  
![\[修改数据库实例\]](http://docs.aws.amazon.com/zh_cn/AmazonRDS/latest/AuroraUserGuide/images/ssl-rotate-cert-modify-aurora.png)

1. 在**连接**部分中，选择 **rds-ca-rsa2048-g1**。  
![\[选择 CA 证书\]](http://docs.aws.amazon.com/zh_cn/AmazonRDS/latest/AuroraUserGuide/images/ssl-rotate-cert-ca-rsa2048-g1.png)

1. 选择**继续**，查看修改摘要。

1. 要立即应用更改，请选择**立即应用**。

1. 在确认页面上，检查您的更改。如果更改正确无误，请选择**修改数据库实例**以保存更改。
**重要**  
安排此操作时，请确保已预先更新客户端信任存储。

   也可以选择 **Back** 编辑您的更改，或选择 **Cancel** 取消更改。

------
#### [ AWS CLI ]

要使用 AWS CLI 将数据库实例的 CA 从 **rds-ca-2019** 更改为 **rds-ca-rsa2048-g1**，请调用 [modify-db-instance](https://docs.aws.amazon.com/cli/latest/reference/rds/modify-db-instance.html) 或 [modify-db-cluster](https://docs.aws.amazon.com/cli/latest/reference/rds/modify-db-cluster.html) 命令。指定数据库实例标识符和 `--ca-certificate-identifier` 选项。

使用 `--apply-immediately` 参数可立即应用更新。默认情况下，此操作安排在您的下个维护时段运行。

**重要**  
安排此操作时，请确保已预先更新客户端信任存储。

**Example**  
以下示例通过将 CA 证书设置为 `rds-ca-rsa2048-g1` 来修改 `mydbinstance`。  
对于 Linux、macOS 或 Unix：  

```
aws rds modify-db-instance \
    --db-instance-identifier mydbinstance \
    --ca-certificate-identifier rds-ca-rsa2048-g1
```
对于：Windows  

```
aws rds modify-db-instance ^
    --db-instance-identifier mydbinstance ^
    --ca-certificate-identifier rds-ca-rsa2048-g1
```
如果您的实例需要重启，可以使用 [modify-db-instance](https://docs.aws.amazon.com/cli/latest/reference/rds/modify-db-instance.html) CLI 命令并指定 `--no-certificate-rotation-restart` 选项。

------

## 通过应用维护来更新 CA 证书
<a name="UsingWithRDS.SSL-certificate-rotation-maintenance-update"></a>

完成以下步骤，通过应用维护来更新 CA 证书。

------
#### [ Console ]

**通过应用维护来更新 CA 证书**

1. 登录 AWS 管理控制台 并通过以下网址打开 Amazon RDS 控制台：[https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/)。

1. 在导航窗格中，选择**证书更新**。  
![\[证书轮换导航窗格选项\]](http://docs.aws.amazon.com/zh_cn/AmazonRDS/latest/AuroraUserGuide/images/ssl-rotate-cert-certupdate.png)

   将显示**需要更新证书的数据库**页面。  
![\[更新数据库的 CA 证书\]](http://docs.aws.amazon.com/zh_cn/AmazonRDS/latest/AuroraUserGuide/images/ssl-rotate-cert-update-multiple.png)
**注意**  
该页面仅显示当前 AWS 区域的数据库实例。如果您在多个 AWS 区域中有数据库，请检查每个 AWS 区域中的该页面，以查看具有旧 SSL/TLS 证书的所有数据库实例。

1. 选择要更新的数据库实例。

   您可以通过选择**计划**来计划下一维护时段的证书轮换。通过选择**立即应用**来立即应用轮换。
**重要**  
如果您在证书到期后遇到连接问题，请使用**立即应用**选项。

1. 

   1. 如果您选择**计划**，系统会提示您确认 CA 证书轮换。此提示还说明更新的计划时段。  
![\[确认证书轮换\]](http://docs.aws.amazon.com/zh_cn/AmazonRDS/latest/AuroraUserGuide/images/ssl-rotate-cert-confirm-schedule.png)

   1. 如果您选择**立即应用**，系统会提示您确认 CA 证书轮换。  
![\[确认证书轮换\]](http://docs.aws.amazon.com/zh_cn/AmazonRDS/latest/AuroraUserGuide/images/ssl-rotate-cert-confirm-now.png)
**重要**  
在计划数据库上的 CA 证书轮换之前，请更新使用 SSL/TLS 和服务器证书进行连接的所有客户端应用程序。这些更新特定于您的数据库引擎。更新这些客户端应用程序后，可以确认 CA 证书轮换。

   要继续，请选中该复选框，然后选择 **Confirm (确认)**。

1. 对要更新的每个数据库实例重复步骤 3 和 4。

------

## 自动服务器证书轮换
<a name="UsingWithRDS.SSL-certificate-rotation-server-cert-rotation"></a>

如果根 CA 支持自动服务器证书轮换，RDS 会自动处理数据库服务器证书的轮换。RDS 使用相同的根 CA 进行自动轮换，因此您无需下载新的 CA 服务包。请参阅[证书颁发机构](UsingWithRDS.SSL.md#UsingWithRDS.SSL.RegionCertificateAuthorities)。

数据库服务器证书的轮换和有效期取决于您的数据库引擎：
+ 如果您的数据库引擎支持无需重启即可轮换，则 RDS 会自动轮换数据库服务器证书，而无需您执行任何操作。RDS 尝试在您首选的维护时段中，在数据库服务器证书的半生命周期轮换您的数据库服务器证书。新的数据库服务器证书的有效期为 12 个月。
+ 如果您的数据库引擎不支持无需重启的证书轮换，Amazon RDS 会在证书有效期过半时或至少在到期前 3 个月，通过 Describe-pending-maintenance-actions API 显示 `server-certificate-rotation` 待处理的维护操作。您可以使用 apply-pending-maintenance-action API 来应用轮换。新的数据库服务器证书的有效期为 36 个月。

使用 [describe-db-engine-versions](https://docs.aws.amazon.com/cli/latest/reference/rds/describe-db-engine-versions.html) 命令并检查 `SupportsCertificateRotationWithoutRestart`标志，以确定数据库引擎版本是否支持无需重启即可轮换证书。有关更多信息，请参阅 [为数据库设置 CA](UsingWithRDS.SSL.md#UsingWithRDS.SSL.RegionCertificateAuthorities.Selection)。

## 将证书导入信任存储的示例脚本
<a name="UsingWithRDS.SSL-certificate-rotation-sample-script"></a>

以下是将证书捆绑包导入信任存储的示例 shell 脚本。

每个示例 Shell 脚本都使用 keytool，它是 Java 开发工具包 (JDK) 的一部分。有关安装 JDK 的信息，请参阅 [JDK 安装指南](https://docs.oracle.com/en/java/javase/17/install/overview-jdk-installation.html)。

------
#### [ Linux ]

下面是一个示例 Shell 脚本，它将证书捆绑包导入 Linux 操作系统上的信任存储。

```
mydir=tmp/certs
if [ ! -e "${mydir}" ]
then
mkdir -p "${mydir}"
fi truststore=${mydir}/rds-truststore.jks storepassword=changeit

curl -sS "https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem"> ${mydir}/global-bundle.pem
awk 'split_after == 1 {n++;split_after=0} /-----END CERTIFICATE-----/ {split_after=1}{print > "rds-ca-" n+1 ".pem"}' < ${mydir}/global-bundle.pem

for CERT in rds-ca-*; do alias=$(openssl x509 -noout -text -in $CERT | perl -ne 'next unless /Subject:/; s/.*(CN=|CN = )//; print')
  echo "Importing $alias"
  keytool -import -file ${CERT} -alias "${alias}" -storepass ${storepassword} -keystore ${truststore} -noprompt
  rm $CERT
done

rm ${mydir}/global-bundle.pem

echo "Trust store content is: "

keytool -list -v -keystore "$truststore" -storepass ${storepassword} | grep Alias | cut -d " " -f3- | while read alias 
do expiry=`keytool -list -v -keystore "$truststore" -storepass ${storepassword} -alias "${alias}" | grep Valid | perl -ne 'if(/until: (.*?)\n/) { print "$1\n"; }'`
   echo " Certificate ${alias} expires in '$expiry'" 
done
```

------
#### [ macOS ]

下面是一个示例 Shell 脚本，它将证书捆绑包导入 macOS 上的信任存储。

```
mydir=tmp/certs
if [ ! -e "${mydir}" ]
then
mkdir -p "${mydir}"
fi truststore=${mydir}/rds-truststore.jks storepassword=changeit

curl -sS "https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem"> ${mydir}/global-bundle.pem
split -p "-----BEGIN CERTIFICATE-----" ${mydir}/global-bundle.pem rds-ca-

for CERT in rds-ca-*; do alias=$(openssl x509 -noout -text -in $CERT | perl -ne 'next unless /Subject:/; s/.*(CN=|CN = )//; print')
  echo "Importing $alias"
  keytool -import -file ${CERT} -alias "${alias}" -storepass ${storepassword} -keystore ${truststore} -noprompt
  rm $CERT
done

rm ${mydir}/global-bundle.pem

echo "Trust store content is: "

keytool -list -v -keystore "$truststore" -storepass ${storepassword} | grep Alias | cut -d " " -f3- | while read alias 
do expiry=`keytool -list -v -keystore "$truststore" -storepass ${storepassword} -alias "${alias}" | grep Valid | perl -ne 'if(/until: (.*?)\n/) { print "$1\n"; }'`
   echo " Certificate ${alias} expires in '$expiry'" 
done
```

------

要了解有关将 SSL 与 Amazon RDS 结合使用的更多最佳实践，请参阅 [Best practices for successful SSL connections to Amazon RDS for Oracle](https://aws.amazon.com/blogs/database/best-practices-for-successful-ssl-connections-to-amazon-rds-for-oracle/)。