45日後に失効するACM証明書

ACM証明書が失効するまでにどんなメールが届くか知っていますか?
2021.05.11

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

Route53 + ACM + CloudFront + S3 。静的サイトをSSL対応でホストするには鉄板の構成ですね。

Amazon Certificate Manager (ACM)で発行した証明書は認証方法をDNS認証にしておけば、基本的には自動更新されますが、自動更新が失敗するケースも存在します。

ACM 証明書の自動更新が失敗するのはなぜですか?

今回は自動更新を失敗させ、証明書の有効期限が失効に近づいていく様子を観察してみました。 決して、個人で検証用に作ったサイトを放置してたわけじゃないです

環境概要

  • サイト構成
    • Route53 + ACM + CloudFront + S3
  • ACMにはDNS認証を利用
    • 諸事情あってドメインの有効期限が先に切れている状態
      • 当然ACMの自動更新は失敗します
  • 証明書の有効期間の終了は2021-04-30

結果

失効の45日前から合計7通、3種類のメールをAWSから受け取りました。

順番に見ていきます。

Action Required - Your certificate renewal

45日前(1.5ヶ月前)に初めて届くメールです。45, 30, 15日前に届きました。

ざっくり言うと、以下の内容が含まれています。

  • ACMのDNS認証による自動更新が失敗していること
    • 失効日時(UTC)
    • 対象のドメイン
    • ACM証明書のリージョンやARN
  • ドメインのDNS設定に適切なCNAMEレコードが存在することを確認する必要があること
    • CNAMEレコードの確認方法
      • マネジメントコンソールでの方法
      • AWS CLIでの方法
  • 問合せ先
    • AWSサポートのURL
    • サポートプランに入っていない場合の対応としてACMのディスカッションフォーラム
Greetings from Amazon Web Services,

You have an SSL/TLS certificate from AWS Certificate Manager in your AWS account that expires on Apr 30, 2021 at 12:00:00 UTC. This certificate includes the primary domain 【ドメイン名】 and a total of 1 domains.

AWS account ID: 【アカウントID】
AWS Region name: us-east-1
Certificate identifier: arn:aws:acm:us-east-1:【アカウントID】:certificate/xxxxxxxxxxxxxxxxxxx

AWS Certificate Manager (ACM) was unable to renew the certificate automatically using DNS validation. You must take action to ensure that the renewal can be completed. If the certificate is not renewed and the current certificate expires, your website or application may become unreachable.

To renew this certificate, you must ensure that the proper CNAME records are present in your DNS configuration for each domain listed below. You can find the CNAME records for your domains by expanding your certificate and its domain entries in the ACM console. You can also use the DescribeCertificate command in the ACM API[1] or the describe-certificate operation in the ACM CLI[2] to find a certificate’s CNAME records. For more information, see Automatic Domain Validation Failure in the ACM troubleshooting guide[3].
The following 1 domains require validation:
【ドメイン名】

If you have questions about this process, you can contact the Support Center[4]. If you don’t have an AWS support plan, you can post a new thread in the AWS Certificate Manager discussion forum[5].

[1] https://docs.aws.amazon.com/acm/latest/APIReference/API_DescribeCertificate.html
[2] https://docs.aws.amazon.com/cli/latest/reference/acm/describe-certificate.html
[3] https://docs.aws.amazon.com/acm/latest/userguide/troubleshooting-renewal.html#troubleshooting-renewal-domain-validation-failure
[4] https://console.aws.amazon.com/support
[5] https://forums.aws.amazon.com/forum.jspa?forumID=206
Sincerely,
Amazon Web Services

Amazon Web Services, Inc. is a subsidiary of Amazon.com, Inc. Amazon.com is a registered trademark of Amazon.com, Inc. This message was produced and distributed by Amazon Web Services Inc., 410 Terry Ave. North, Seattle, WA 98109-5210

URGENT Action Required - Your certificate renewal

失効の一週間からタイトルに「URGENT」がつきます。緊急ということですね。

7, 3, 1日前とだんだん間隔が短くなることにドキドキが増します。なお、変わるのはタイトルのみで本文は変わっていません。

Your certificate has expired

ついに失効してしまいました。なお、届いたのはJSTで4/30の23:30頃、UTCだと4/30の14:30ですね。失効後、2.5時間といったところです。

ざっくりな内容としては、「Action Required - Your certificate renewal」とほぼ同じですが、以下が差分です。

  • 対象の証明書がすでに失効しているとの情報
  • (前のメールにあった)DNS認証に必要なCNAMEレコードの確認方法の記載が無くなっている
Greetings from Amazon Web Services,

You have an SSL/TLS certificate from AWS Certificate Manager (ACM) in your AWS account that expired on Apr 30, 2021 at 12:00:00 UTC. This certificate includes the primary domain 【ドメイン名】 and a total of 1 domains.

AWS account ID: 【アカウントID】
AWS Region name: us-east-1
Certificate identifier: arn:aws:acm:us-east-1:【アカウントID】:certificate/xxxxxxxxxxxxxxxxxxx

AWS Certificate Manager (ACM) was unable to automatically renew the certificate using DNS validation. To renew this certificate, you must ensure that the proper CNAME records are present in your DNS configuration for each domain listed below.
The following 1 domains require validation:
【ドメイン名】

As a result the current certificate expired on Apr 30, 2021 at 12:00:00 UTC. Your website or application might be unreachable at this time.

To obtain a new certificate, review the ACM User Guide[1]. If you have questions about this process, you can contact the Support Center[2]. If you don’t have an AWS support plan, you can post a new thread in the AWS Certificate Manager discussion forum[3].

[1] https://docs.aws.amazon.com/acm/latest/userguide/gs-acm-request-public.html
[2] https://console.aws.amazon.com/support
[3] https://forums.aws.amazon.com/forum.jspa?forumID=206

Sincerely,
Amazon Web Services

Amazon Web Services, Inc. is a subsidiary of Amazon.com, Inc. Amazon.com is a registered trademark of Amazon.com, Inc. This message was produced and distributed by Amazon Web Services Inc., 410 Terry Ave. North, Seattle, WA 98109-5210

対策

切れる前に通知が来ることは分かったけれど、もっと早く知りたいし、できればちゃんとモニタリングしておきたい。そんなときには以下がよさそうです。CloudWatchに統合されていて任意の日数でアラームを設定できるのが便利ですね。

また、30日前からにはなりますが、Security Hubのコントロールでチェック/通知も可能です。

[ACM.1] インポートされた ACM 証明書は、指定した期間後に更新する必要があります

他にもMackerel等でのURL外形監視で証明書の有効期限を監視できるケースもあるようです。

URL外形監視にてSSL証明書の有効期限を監視できるようになりました

おわりに

今回はACM証明書の有効期限が失効に近づいていくごとにAWSから送られてくるメールをまとめてみました。n=1なので、全てのアカウントで同様の対応になるかは言い切れない部分がありますが、おそらく証明書が失効しそうな場合や失効後にはAWSから英文メールでの連絡が届くと思います(英文メールなので見逃し注意ですね)。

こういった自体を避けるためにもドメインや証明書の対応はツールを活用しつつ、計画的に行いたいと思いました。願わくばこれらのメールを見ないで済むようにしたいものです。

以上、何かのお役に立てれば幸いです。