Search code examples
node.jsexpressdns

Check DKIM Signature From Domain


Is there a way to check the DKIM Signature via Node JS?

I've tried something like this

dns.resolveTxt('acme.com', (err, addresses) => console.log(addresses));

But it's only providing the SPF record. Perhaps there is a subdomain I need to check under the domain for the DKIM Signature?

My end goal is to just determine if the domain has a DKIM set up or not. Thank you!


Solution

  • i created a webserver. I can send emails to [email protected] therefore i created a dkim like this on the dns : mail._domainkey.domain.com.

    i can, for exemple, use dig to get txt data stored on the dns. It goes like this :

    $> dig mail._domainkey.domain.com. txt
    ...
    mail._domainkey.domain.com. 3600 IN TXT "v=DKIM1; h=sha256; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAO...yUgBBeewIDAQAB"
    ...
    

    but you would need to know the selector of the dkim. (for me its "mail" but it can be anything) the email sender chooses which one it uses, and write it in the email headers.

    in nodejs this works for my domain :

    require('dns').resolveTxt('mail._domainkey.domain.com.', console.log);
    

    see more here : https://serverfault.com/questions/625008/find-dkim-and-dmarc-records/832546