

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 使用加密保護資料
<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 加密資料庫叢集可以保護您的資料，避免基礎儲存體受到未經授權人員的存取，為資料提供另一層保護。在 Amazon Aurora 中於 2026 年 2 月 18 或之後建立的所有新資料庫叢集，都會使用業界標準的 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 您的帳戶建立 AWS 受管金鑰 適用於 Amazon Aurora 的 。每個區域的 AWS 受管金鑰 Amazon Aurora AWS 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 key 管理](Overview.Encryption.Keys.md) 中的 [AWS KMS keys](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#kms_keys)。

## 加密 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 管理主控台 並開啟位於 https：//[https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/) 的 Amazon RDS 主控台。

1. 在導覽窗格中，選擇 **Databases** (資料庫)。

1. 選擇您要檢查的資料庫叢集名稱，以檢視其詳細資訊。

1. 選擇 **Configuration** (組態) 索引標籤，然後勾選 **Encryption** (加密) 值。  
![\[檢查資料庫叢集的靜態加密\]](http://docs.aws.amazon.com/zh_tw/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 加密。

**注意**  
db.t2.micro 資料庫執行個體類別無法使用 Amazon Aurora 加密。

## 傳輸中加密
<a name="Overview.Encryption.InTransit"></a>

**在實體層加密**  
在離開 AWS 安全設施之前， AWS 區域 透過 AWS 全球網路周遊的所有資料都會在實體層自動加密。AZ 之間的所有流量都會加密。額外的加密層 (包括本節所列的加密層) 可能會提供額外的保護。

**Amazon VPC 對等互連和 Transit Gateway 跨區域對等互連提供的加密**  
所有使用 Amazon VPC 和 Transit Gateway 對等互連的跨區域流量都會在離開區域時自動進行批量加密。在離開 AWS 安全設施之前，會在實體層自動為所有流量提供另一層加密。

**執行個體間的加密**  
AWS 在所有類型的資料庫執行個體之間提供安全和私有連線。此外，某些執行個體類型使用基礎 Nitro System 硬體的卸載功能，以自動加密執行個體之間的傳輸中流量。此加密機制使用帶有關聯資料的認證加密 (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 受管金鑰* 是帳戶中的 KMS 金鑰，由與 整合的 AWS 服務代表您建立、管理和使用 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 CLI或 AWS KMS API 中使用 [AWS Key Management Service (AWS KMS)](https://docs.aws.amazon.com/kms/latest/developerguide/)。若要檢視透過 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` 的完整存取。反之，使用 [kms:ViaService 條件金鑰](https://docs.aws.amazon.com/kms/latest/developerguide/policy-conditions.html#conditions-kms-via-service)，只允許使用者在由 AWS 服務代使用者建立授予時，才在 KMS 金鑰上建立授予。

您可以透過各種方式使 IAM 政策更加嚴格。例如，若要允許客戶受管金鑰僅用於源自 Aurora 的請求，您可以搭配 `rds.<region>.amazonaws.com` 值使用 [kms:ViaService 條件金鑰](https://docs.aws.amazon.com/kms/latest/developerguide/policy-conditions.html#conditions-kms-via-service)。您也可以使用 [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)。加密內容是[額外的驗證資料](https://docs.aws.amazon.com/crypto/latest/userguide/cryptography-concepts.html#term-aad) (AAD)， AWS KMS 用於確保資料完整性。為加密操作指定加密內容時，此服務必須為解密操作指定相同的加密內容。否則，解密會失敗。加密內容也會寫入 [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>

您可以從應用程式使用 Secure Socket Layer (SSL) 或 Transport Layer Security (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_tw/AmazonRDS/latest/AuroraUserGuide/images/certificate-authority-overview.png)


Amazon RDS 提供下列 CA 來簽署資料庫的資料庫伺服器憑證。


****  

| 憑證授權單位 (CA) | Description | Common name (CN) (通用名稱 (CN)) | 
| --- | --- | --- | 
|  rds-ca-rsa2048-g1  |  在大多數 AWS 區域中，使用搭配 RSA 2048 私密金鑰演算法和 SHA256 簽署演算法的憑證認證機構。 在 中 AWS GovCloud (US) Regions，此 CA 使用憑證授權機構搭配 RSA 2048 私有金鑰演算法和 SHA384 簽署演算法。 此 CA 支援自動伺服器憑證輪換。  | Amazon RDS 區域識別符根 CA RSA2048 G1 | 
|  rds-ca-rsa4096-g1  |  使用搭配 RSA 4096 私密金鑰演算法和 SHA384 簽署演算法的憑證認證機構。此 CA 支援自動伺服器憑證輪換。  | Amazon RDS 區域識別符根 CA RSA4096 G1 | 
|  rds-ca-ecc384-g1  |  使用搭配 ECC 384 私密金鑰演算法和 SHA384 簽署演算法的憑證認證機構。此 CA 支援自動伺服器憑證輪換。  | Amazon RDS 區域識別符根 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。您可以使用 AWS 帳戶 [modify-certificates](https://docs.aws.amazon.com/cli/latest/reference/rds/modify-certificates.html) 命令覆寫 的預設 CA。

可用的 CA 取決於資料庫引擎和資料庫引擎版本。使用 時 AWS 管理主控台，您可以使用**憑證授權單位**設定選擇 CA，如下圖所示。

![\[憑證授權單位選項\]](http://docs.aws.amazon.com/zh_tw/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) 命令查看帳戶的可用 CAs。此命令也會在輸出中顯示 `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
```

輸出類似如下。可用的 CA 列示在 `SupportedCACertificateIdentifiers` 中。輸出也會顯示 DB 引擎版本是否支援輪換憑證，而不需在 `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_tw/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 (US) 區域的憑證套件都包含下列根 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 Proxy 和 Aurora Serverless v1 使用 來自 AWS Certificate Manager (ACM) 的憑證。如果您是使用 RDS Proxy，您不需要下載 Amazon RDS 憑證或更新使用 RDS Proxy 連線的應用程式。如需詳細資訊，請參閱 [搭配 RDS Proxy 使用 TLS/SSL](rds-proxy.howitworks.md#rds-proxy-security.tls)。  
如果您使用 Aurora Serverless v1，則不需要下載 Amazon RDS 憑證。如需詳細資訊，請參閱 [搭配 Aurora Serverless v1 使用 TLS/SSL](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-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)  | 
| 非洲 (開普敦) |  [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)  | 
| 亞太區域 (香港) |  [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)  | 
| Middle East (Bahrain) |  [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 月到期。如果您使用或計劃使用 Secure Sockets Layer (SSL) 或 Transport Layer Security (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 憑證，請使用下列方法：
+  [透過修改資料庫執行個體來更新憑證授權機構憑證](#UsingWithRDS.SSL-certificate-rotation-updating) 
+  [透過套用維護來更新憑證授權機構憑證](#UsingWithRDS.SSL-certificate-rotation-maintenance-update) 

在更新您的資料庫執行個體以使用新的 CA 憑證之前，請確定您已更新連線至 RDS 資料庫的用戶端或應用程式。

## 輪換憑證的考量
<a name="UsingWithRDS.SSL-certificate-rotation-considerations"></a>

在輪換憑證之前，請考量下列情況：
+ Amazon RDS Proxy 和 Aurora Serverless v1 使用來自 AWS Certificate Manager (ACM) 的憑證。如果您使用 RDS Proxy，當您輪換 SSL/TLS 憑證時，不需要更新使用 RDS Proxy 連線的應用程式。如需詳細資訊，請參閱 [搭配 RDS Proxy 使用 TLS/SSL](rds-proxy.howitworks.md#rds-proxy-security.tls)。
+ 如果您使用 Aurora Serverless v1，則不需要下載 Amazon RDS 憑證。如需詳細資訊，請參閱 [搭配 Aurora Serverless v1 使用 TLS/SSL](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 憑證識別符，將 `modify-db-instance` 命令。您可以使用 `describe-db-engine-versions` 命令，尋找適用於特定資料庫引擎和資料庫引擎版本的 CA。

  如果您是在 2020 年 7 月 28 日之後建立資料庫或更新其憑證，則不需要執行任何動作。如需詳細資訊，請參閱 [Go GitHub 問題編號 39568](https://github.com/golang/go/issues/39568)。

## 透過修改資料庫執行個體來更新憑證授權機構憑證
<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 加密與資料庫叢集的連線](UsingWithRDS.SSL.md) 所述，下載新的 SSL/TLS 憑證。

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 和新 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選項。依預設，此操作排定在下一個維護時段執行。  
若要為您的叢集 CA 設定與預測 RDS 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 管理主控台 ，並在 [https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/)：// 開啟 Amazon RDS 主控台。

1. 在導覽窗格中選擇**資料庫**，然後選擇您要修改的資料庫執行個體。

1. 選擇 **Modify** (修改)。  
![\[修改資料庫執行個體或\]](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/AuroraUserGuide/images/ssl-rotate-cert-modify-aurora.png)

1. 在**連線**區段中，選擇 **rds-ca-rsa2048-g1**。  
![\[選擇 CA 憑證\]](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/AuroraUserGuide/images/ssl-rotate-cert-ca-rsa2048-g1.png)

1. 選擇 **Continue (繼續)**，並檢查修改的摘要。

1. 若要立即套用變更，請選擇 **Apply immediately** (立即套用)。

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` 選項。

------

## 透過套用維護來更新憑證授權機構憑證
<a name="UsingWithRDS.SSL-certificate-rotation-maintenance-update"></a>

透過套用維護，執行下列步驟來套用 CA 憑證。

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

**透過套用維護來更新 CA 憑證**

1. 登入 AWS 管理主控台 ，並在 [https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/)：// 開啟 Amazon RDS 主控台。

1. 在導覽窗格中，選擇**憑證更新**。  
![\[憑證輪換導覽窗格選項\]](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/AuroraUserGuide/images/ssl-rotate-cert-certupdate.png)

   **需要更新憑證的資料庫**頁面隨即顯示。  
![\[更新資料庫的 CA 憑證\]](http://docs.aws.amazon.com/zh_tw/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_tw/AmazonRDS/latest/AuroraUserGuide/images/ssl-rotate-cert-confirm-schedule.png)

   1. 如果您選擇**立即套用**，系統會提示您確認 CA 憑證輪換。  
![\[確認憑證輪換\]](http://docs.aws.amazon.com/zh_tw/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 會透過 Describe-pending-maintenance-actions API、憑證的一半生命週期，或在過期前至少 3 個月顯示`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 搭配使用的最佳實務，請參閱[與 Amazon RDS for Oracle 成功進行 SSL 連線的最佳實務](https://aws.amazon.com/blogs/database/best-practices-for-successful-ssl-connections-to-amazon-rds-for-oracle/)。