
嘗試找出在具有多個彈性 IPS 的單一 EC2 上實施 DKIM 的最佳實務。
# /etc/opendkim.conf
...
Mode sv
Canonicalization relaxed/simple
ExternalIgnoreList refile:/etc/opendkim/TrustedHosts
InternalHosts refile:/etc/opendkim/TrustedHosts
KeyTable refile:/etc/opendkim/KeyTable
SigningTable refile:/etc/opendkim/SigningTable
SignatureAlgorithm rsa-sha256
...
# /etc/opendkim/KeyTable
default._domainkey.example.com example.com:hp-hv-1:/etc/opendkim/keys/default.private
default._domainkey.example.com example.com:hp-hv-2:/etc/opendkim/keys/default.private
# /etc/opendkim/SigningTable
*@example.com default._domainkey.example.com
然後我有兩個 DNS 記錄:
hp-hv-1._domainkey.example.com TXT "v=DKIM1;k=rsa;p=default.txt_key_goes_here"
hp-hv-2._domainkey.example.com TXT "v=DKIM1;k=rsa;p=default.txt_key_goes_here"
對於同一 EC2 執行個體上的兩個 postfix 實例,每個執行個體都有下列 $myhostname:
# postfixmulti instance #1
myhostname = hp-hv-1
# postfixmulti instance #2
myhostname = hp-hv-2
兩個 postfix 執行個體位於同一 EC2 執行個體上,因此它們共用相同的 default.private/default.txt 私鑰/公鑰對,因此無需向 KeyTable 和 SigningTable 新增更多行。據我所知,如果我想實作多個網域(我不這樣做),我只需要向 KeyTable 和 SigningTable 添加額外的行。
但是,當我測試我的 DKIM 設定時,我不斷收到「通過:中性」回應,表示電子郵件未簽名,但它們是,我可以在日誌檔案中看到它:
# snippet from /var/log/maillog
Sep 25 15:15:31 service-a-4 opendkim[27420]: 5B4A3625F0: DKIM-Signature field added (s=hp-hv-1, d=example.com)
我缺什麼?
版本:
CentOS 6.5
Postfix v2.6.6
Opendkim v2.9
答案1
好吧,我顯然很困惑,我一直認為 DKIM 簽名字段中的“s”應該從 postfix 配置中識別 $myhostname,但實際上並非如此。閱讀更多有關DKIM 金鑰輪換,它最終戴在了我身上,「s」只是從 KeyTable、SigningTable 和 DNS 中使用的選擇器。
檢查一下:
# /etc/opendkim/KeyTable
# Format: selector(1) domain:selector(2):/path/to/key
# selector(1) is used in the /etc/opendkim/SigningTable
# selector(2) is built into the DKIM signature for every email sent, which is used to lookup the DNS TXT entry: mail-1_r-1._domainkey.example.com
mail-1_r-1._domainkey.example.com example.com:mail-1_r-1:/etc/opendkim/keys/mail-1_r-1.private
現在,如果我想旋轉密鑰,我會這樣做:
# /etc/opendkim/KeyTable
# Generate new private/public key pair, and rename accordingly
mail-1_r-1._domainkey.example.com example.com:mail-1_r-1:/etc/opendkim/keys/mail-1_r-1.private
mail-1_r-2._domainkey.example.com example.com:mail-1_r-2:/etc/opendkim/keys/mail-1_r-2.private
然後在簽名表中:
# /etc/opendkim/SigningTable
*@shouttag.com mail_r-1._domainkey.example.com
*@shouttag.com mail_r-2._domainkey.example.com
然後對於 DNS 項目,您將擁有以下內容
mail_r-1.domainkey.example.com "v=DKIM1;k=rsa;p=mail_r-1.txt_key_goes_here"
mail_r-2.domainkey.example.com "v=DKIM1;k=rsa;p=mail_r-2.txt_key_goes_here"
這些 DNS 項目用於協助驗證電子郵件是否確實是從您的網域發送的(因此稱為網域金鑰識別郵件)。然後大約 7 天后,您可以刪除 mail_r-1.domainkey.example.com。