List,

I just put DKIM on my mail system, but gmail rejects with "body hash did not verify", so something is wrong with how I'm hashing.  Does this code look reasonable?

 sub dkim_sign {
        my $dkim = Mail::DKIM::Signer->new(
                Algorithm => "rsa-sha1",
                Method => "relaxed",
                Domain => "domain.net",
                Selector => "beta",
                KeyFile => "/etc/mail/dkim.key");
        if (open(TOSIGN, "<SIGNME")) {
                while(<TOSIGN>) {
                        # remove local line terminators
                        chomp;
                        s/\015$//;

                        # use SMTP line terminators
                        $dkim->PRINT("$_\015\012");
                }
                close(TOSIGN);
                $dkim->CLOSE();
                my $signature = $dkim->signature()->as_string();
                $signature =~ s/^DKIM-Signature:\s+//i;
                action_add_header('DKIM-Signature', $signature);
        }
}

sub filter_wrapup {
  my($entity) = @_;

  open(my $fh, '>', "./SIGNME") or die "Could not open file 'SIGNME' $!";
  print $fh $entity->stringify();
  close $fh;

  dkim_sign();

}

I got the key from https://dkimcore.org/tools/ to make sure I got something workable, perhaps that is the issue.
_______________________________________________
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID.  You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list MIMEDefang@lists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang

Reply via email to