This commit is contained in:
2026-05-24 17:15:48 +00:00
parent 329d5c665a
commit 063b3b643f
22 changed files with 1348 additions and 92 deletions
+7 -2
View File
@@ -327,13 +327,18 @@ func Verify(message []byte) (domain string, err error) {
}
// DNSRecord returns the DKIM TXT record string for publishing.
func DNSRecord(selector, domain, publicKeyPEM string) string {
// algo must be "rsa2048" or "ed25519"; any other value defaults to "rsa".
func DNSRecord(selector, domain, publicKeyPEM, algo string) string {
block, _ := pem.Decode([]byte(publicKeyPEM))
var p string
if block != nil {
p = base64.StdEncoding.EncodeToString(block.Bytes)
}
return fmt.Sprintf("%s._domainkey.%s. IN TXT \"v=DKIM1; k=rsa; p=%s\"", selector, domain, p)
k := "rsa"
if algo == "ed25519" {
k = "ed25519"
}
return fmt.Sprintf("%s._domainkey.%s. IN TXT \"v=DKIM1; k=%s; p=%s\"", selector, domain, k, p)
}
// SPFRecord returns the recommended SPF TXT record for a domain.