GeekFactory

int128.hatenablog.com

ACMのドメイン所有確認メールをSESで受信

ACMAmazon Certificate Manager)でSSL証明書を発行するには、ドメイン管理者に送付されるメールで承認をクリックする必要があります。ドメインの管理組織が異なる場合やメールサーバを用意していない場合は、ドメイン管理者へのメールをSESで受け取ることも可能です。

以下のフローでメールを受信します。

  1. ACM(メール送信)
  2. Route53(MXレコード参照)
  3. SES(メール受信)
  4. S3(メール格納)

具体的なオペレーションは以下を参照してください。

dev.classmethod.jp

S3には生のメールが格納されます。承認用のURLを見つけて開けばOKです。

参考までに、ACMから送付されるメールはマルチパートなので以下の形式になっています。

  • ヘッダ
  • マルチパートのヘッダ
  • テキスト形式
  • マルチパートのヘッダ
  • HTML形式

メールの一部を抜粋します。

Return-Path: <****@bounces.certificates.amazon.com>
Received: from a11-104.smtp-out.amazonses.com (a11-104.smtp-out.amazonses.com [54.240.11.104])
 by inbound-smtp.us-east-1.amazonaws.com with SMTP id ****
 for webmaster@****;
 Sat, 22 Oct 2016 03:52:16 +0000 (UTC)
X-SES-Spam-Verdict: PASS
X-SES-Virus-Verdict: PASS
Received-SPF: pass (spfCheck: domain of bounces.certificates.amazon.com designates 54.240.11.104 as permitted sender) client-ip=54.2
40.11.104; envelope-from=****@bounces.certificates.amazon.com; helo=a11-104.
smtp-out.amazonses.com;
(中略)

------=_Part_53514382_216701969.1477108335332
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Greetings from Amazon Web Services,

We received a request to issue an SSL/TLS certificate for ****.

Verify that the domain, AWS account ID, and certificate identifier
below correspond to a request from you or someone in your organization.

Domain: ****
AWS account number: ****
AWS Region name: ****
Certificate identifier: ****

To approve this request, go to Amazon Certificate Approvals at
https://certificates.amazon.com/approvals?code=****&context=****
and follow the instructions on the page.

If you choose not to approve this request, you do not need to do anything.
(中略)
------=_Part_53514382_216701969.1477108335332
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.=
w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=3D"http://www.w3.org/1999/xhtml">
(中略)
------=_Part_53514382_216701969.1477108335332--