

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

# 中的私有憑證續約 AWS Certificate Manager
<a name="renew-private-cert"></a>

由私有 CA 從 簽署的 ACM 憑證 AWS 私有 CA 符合受管續約的資格。與公開信任的 ACM 憑證不同，私有 PKI 的憑證不需要驗證。系統管理員在用戶端信任存放區中安裝適當的根憑證授權機構憑證時，就會建立信任。

**注意**  
只有使用 ACM 主控台或 ACM API 的 [RequestCertificate](https://docs.aws.amazon.com/acm/latest/APIReference/API-RequestCertificate.html) 動作取得的憑證才符合受管續約的資格。 AWS 私有 CA 使用 AWS 私有 CA API 的 [IssueCertificate](https://docs.aws.amazon.com/acm/latest/APIReference/API_IssueCertificate.html) 動作直接從 發出的憑證不會由 ACM 管理。

在受管憑證過期前 60 天，ACM 會自動嘗試每小時續約一次。這包括手動匯出和安裝的憑證 (例如在內部部署資料中心裡)。客戶也可以隨時使用 ACM API 的 [RenewCertificate](https://docs.aws.amazon.com/acm/latest/APIReference/API_RenewCertificate.html) 動作強制續約。如需強制續約的 Java 實作範例，請參閱 [續約憑證](sdk-renew.md)。

續約後，會依下列其中一種方式將憑證部署至服務：
+ 如果憑證**有**與 ACM [整合服務](https://docs.aws.amazon.com/acm/latest/userguide/acm-services.html)相關聯，則新憑證會取代舊憑證，而不需要客戶採取額外動作。
+ 如果憑證**沒有**與 ACM [整合服務](https://docs.aws.amazon.com/acm/latest/userguide/acm-services.html)相關聯，則需要客戶採取動作，才能匯出並安裝續約的憑證。您可以手動執行這些動作，或在 [AWS Health](https://docs.aws.amazon.com/health/latest/ug/)、[Amazon EventBridge](https://docs.aws.amazon.com/eventbridge/latest/userguide/) 以及 [AWS Lambda](https://docs.aws.amazon.com//lambda/latest/dg/getting-started.html) 的協助下執行，如下所示：如需詳細資訊，請參閱[自動化匯出續約的憑證](#automating-export)

## 自動化匯出續約的憑證
<a name="automating-export"></a>

下列程序提供了一個範例解決方案，可在 ACM 續約憑證時自動化私有 PKI 憑證的匯出作業。此範例僅會從 ACM 匯出憑證及其私有金鑰；匯出後，憑證仍然必須安裝在其目標裝置上。

**若要使用主控台自動化憑證匯出作業**

1. 遵循 AWS Lambda 開發人員指南中的程序，建立和設定呼叫 ACM 匯出 API 的 Lambda 函數。

   1. [建立 Lambda 函數](https://docs.aws.amazon.com/lambda/latest/dg/getting-started-create-function.html)。

   1. 為您的函數[建立 Lambda 執行角色](https://docs.aws.amazon.com/lambda/latest/dg/lambda-intro-execution-role.html)，並將下列信任政策加入函數。此政策可授與函數中程式碼的許可，以擷取已續約的憑證和私有金鑰，方法是呼叫 ACM API 的 [ExportCertificate](https://docs.aws.amazon.com/acm/latest/APIReference/API_ExportCertificate.html) 動作。

------
#### [ JSON ]

****  

      ```
      {
         "Version":"2012-10-17",		 	 	 
         "Statement":[
            {
               "Effect":"Allow",
               "Action":"acm:ExportCertificate",
               "Resource":"*"
            }
         ]
      }
      ```

------

1.  

   [在 Amazon EventBridge 中建立規則](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-create-rule.html)以接聽 ACM 運作狀態事件，並在檢測到 ACM 運作狀態事件時呼叫您的 Lambda 函數。ACM 每次嘗試續約憑證時都會寫入 AWS Health 事件。如需這些通知的詳細資訊，請參閱「[使用 Personal Health Dashboard (PHD) 檢查狀態](check-certificate-renewal-status.md#check-renewal-status-phd)」。

   加入下列事件模式來設定規則。

   ```
   {
      "source":[
         "aws.health"
      ],
      "detail-type":[
         "AWS Health Event"
      ],
      "detail":{
         "service":[
            "ACM"
         ],
         "eventTypeCategory":[
            "scheduledChange"
         ],
         "eventTypeCode":[
            "AWS_ACM_RENEWAL_STATE_CHANGE"
         ]
      },
      "resources":[
         "arn:aws:acm:region:account:certificate/certificate_ID"
      ]
   }
   ```

1. 在目標系統上手動安裝憑證以完成續約程序。

## 測試私有 PKI 憑證的受管續約
<a name="manual-renewal"></a>

您可以使用 ACM API 或 AWS CLI 手動測試 ACM 受管續約工作流程的組態。這樣做可以確認您的憑證在過期時會由 ACM 自動續約。

**注意**  
您只能測試 發行和匯出的憑證續約 AWS 私有 CA。

使用下述 API 動作或 CLI 命令時，ACM 會嘗試續約憑證。如果續約成功，ACM 會更新管理主控台或 API 輸出中顯示的憑證中繼資料。如果憑證與 ACM [整合服務](https://docs.aws.amazon.com/acm/latest/userguide/acm-services.html)相關聯，則會部署新憑證，並在 Amazon CloudWatch Events 中產生續約事件。如果續約失敗，ACM 會傳回錯誤並建議補救動作。(您可以使用 [describe-certificate](https://docs.aws.amazon.com/cli/latest/reference/acm/describe-certificate.html) 命令。) 如果憑證未透過整合服務部署，您仍需要將憑證匯出並手動安裝到您的資源上。

**重要**  
若要使用 ACM 續約您的 AWS 私有 CA 憑證，您必須先授予 ACM 服務主體許可才能執行此操作。如需詳細資訊，請參閱[指派憑證續約許可給 ACM](https://docs.aws.amazon.com/privateca/latest/userguide/assign-permissions.html#PcaPermissions)。

**若要手動測試憑證續約 (AWS CLI)**

1. 使用 [renew-certificate](https://docs.aws.amazon.com/cli/latest/reference/acm/renew-certificate.html) 命令來續約私有匯出憑證。

   ```
   aws acm renew-certificate \
   	--certificate-arn arn:aws:acm:region:account:certificate/certificate_ID
   ```

1. 然後，使用 [describe-certificate](https://docs.aws.amazon.com/cli/latest/reference/acm/describe-certificate.html) 命令來確認憑證的續約詳細資訊已更新。

   ```
   aws acm describe-certificate \
   	--certificate-arn arn:aws:acm:region:account:certificate/certificate_ID
   ```

**手動測試憑證續約 (ACM API)**
+ 傳送 [RenewCertificate](https://docs.aws.amazon.com/acm/latest/APIReference/API_RenewCertificate.html) 請求，指定私有憑證的 ARN 以便續約。然後，使用 [DescribeCertificate](https://docs.aws.amazon.com/acm/latest/APIReference/API_DescribeCertificate.html) 操作來確認憑證的續約詳細資訊已更新。