0

I'm using MimeKit to send emails and the use of DKIM to sign them has been broached. I've looked at the example on the MimKit site, and googled the terms but found no answers.

Public Shared Sub DkimSign(ByVal message As MimeMessage)
  Dim headers = New HeaderId() {HeaderId.From, HeaderId.Subject, HeaderId.Date}
  Dim headerAlgorithm = DkimCanonicalizationAlgorithm.Simple
  Dim bodyAlgorithm = DkimCanonicalizationAlgorithm.Simple
  Dim signer = New DkimSigner("filename", "domain", "selector") With {.SignatureAlgorithm = DkimSignatureAlgorithm.RsaSha1, .AgentOrUserIdentifier = "@eng.example.com"}

  message.Prepare(EncodingConstraint.SevenBit)
  message.Sign(signer, headers, headerAlgorithm, bodyAlgorithm)

End Sub

When instantiating the signer it requires a filename, domain and selector. If I'm sending an email from "bob@website.com" I would assume that the physical file would be placed on the root of the site and the instantiation would look something like this:

Dim signer = New DkimSigner("dkim.txt", "website.com", "") With {.SignatureAlgorithm = DkimSignatureAlgorithm.RsaSha1, .AgentOrUserIdentifier = "???"}

But not sure the format/reason for the AgentOrUserIdentifier ... can anyone edify me or correct me if my assumptions are wrong?

4

1 回答 1

2

fileName参数是用于对消息进行签名的私钥的路径。我不确定您为什么希望它位于站点的根目录或为什么将其称为 dkim.txt,但我几乎可以保证这两个假设都是错误的。

接收客户端使用Aselector在 DNS 记录中定位正确的公钥,因为同一个域可能有多个用于签名的密钥。

AgentOrUserIdentifier对应于您在 DKIM-Signature 标头中找到的参数i=,并指定负责签名的用户或代理。

于 2018-02-08T16:19:11.300 回答