Windows設置郵件DKIM協定
DKIM(DomainKeys Identified Mail)是一種電子郵件的驗證技術,使用密碼學的基礎提供了簽名與驗證的功能。
一般來說,發送方會在電子郵件的標頭插入
1 | DKIM-Signature |
及電子簽名資訊。而接收方則透過DNS查詢得到公開金鑰後進行驗證。
DKIM是由DomainKeys所改進的協定,大多數的運作方式與DomainKeys相同。在2007年2月時,DKIM被列入互聯網工程工作小組(IETF)的標準提案(Proposed Standard),並於同年5月成為正式標準(Standards Track)。
DKIM 與 Domainkeys 是兩個不同的協定
據我了解Domainkeys是舊的協定已經不再更新,如果要設定,也要看看你的郵件主機是否支援。
DKIM設定開始>
Openssl,用它來生成私鑰與公鑰,在這裡下載openssl的windows版本,安裝前需先安裝Visual C++ 2008 Redistributables,安裝好後開始來生密鑰。
默認openssl安裝在C:\OpenSSL-Win64,按照下面命令生成
cd C:\OpenSSL-Win64\bin
openssl.exe genrsa -out rsa.private 1024 //生成私鑰
openssl.exe rsa -in rsa.private -out rsa.public -pubout -outform PEM //生成公鑰 -
然後會看到bin目錄下多了兩個文件rsa.private與rsa.public, 先把私鑰rsa.private移到郵件伺服器的安裝目錄去,然後用記事本打開rsa.public,裡面有一串base64編碼的字符串,複製,然後到 DNS server去添加一個txt記錄,名稱 為mail._domainkey(mail這個可自定義,後面的_domainkey是必需的),記錄值為k=rsa; t=y; p=base64,這個p=後面的base64換成rsa.public裡面的那串字符串,t=y表示測試模式,告訴接收服務器忽略DKIM簽名,可以去掉,也可以加個v=DKIM1來說明版本
添加完txt記錄,可以用以下命令來查看一下是否生效了
nslookup
set type=txt
mail._domainkey.domain.com //domain.com替換為你的域名
這裡公鑰就設置完成,然後在郵件伺服器設定中設置私鑰。
Enabled DKIM
Private key file選擇之前移到郵件伺服器目錄的rsa.private文件
Selector裡填入mail,這個要跟添加txt記錄時_domainkey前面的值一致。
Signing algorithm,簽名算法,SHA1肯定是趕不上SHA256安全,不過SHA256加密時佔用CPU資源會高一些,根據自己的需求選吧。
設置完成,發個郵件試試!看看信件完整標頭是不是有DKIM簽證!
- b = the actual digital signature of the contents (headers and body) of the mail message
- bh = the body hash
- d = the signing domain
- s = the selector
- v = the version
- a = the signing algorithm
- c = the canonicalization algorithm(s) for header and body
- q = the default query method
- l = the length of the canonicalized part of the body that has been signed
- t = the signature timestamp
- x = the expire time
- h = the list of signed header fields, repeated for fields that occur multiple times
以下是幾個用來測試DKIM是否正常運作的服務信箱
- sa-test@sendmail.net
- dkim-test@dkim.org
- dkim-test@altn.com
- autorespond+dkim@dk.elandsys.com
- dktest@blackops.org
- http://www.appmaildev.com/hk/dkim/
這些信箱在收到信後,會回覆一封信件給你,列出檢查的結果。
發表評論
想要留言嗎?歡迎歡迎!