| Posted on 2012-05-17 08:32:39.929976-07 by musicstack |
| Can't get DKIM signature to validate - dkim=neutral (bad format) |
|
I have been having a huge problem getting DKIM to validate properly. I keep getting back: dkim=neut
+ral (bad format)
I have the DNS record set up properly, so i can only assume it is something I'm doing to not sign t
+he email correctly.
I send a test message (using Amazon SES) and this is the full header I get back:
X-Antivirus: AVG for E-mail
Delivered-To: musicstack@gmail.com
Received: by 10.182.5.70 with SMTP id q6csp14332obq;
Thu, 17 May 2012 08:26:27 -0700 (PDT)
Received: by 10.224.201.5 with SMTP id ey5mr16946464qab.74.1337268386330;
Thu, 17 May 2012 08:26:26 -0700 (PDT)
Return-Path: <000001375b6836e5-eabe0fd6-f6ec-468c-9e77-7269341f59e5-000000@amazonses.com>
Received: from a192-83.smtp-out.amazonses.com (a192-83.smtp-out.amazonses.com. [199.255.192.83])
by mx.google.com with ESMTP id ep7si8411487qab.19.2012.05.17.08.26.26;
Thu, 17 May 2012 08:26:26 -0700 (PDT)
Received-SPF: pass (google.com: domain of 000001375b6836e5-eabe0fd6-f6ec-468c-9e77-7269341f59e5-000
+000@amazonses.com designates 199.255.192.83 as permitted sender) client-ip=199.255.192.83;
Authentication-Results: mx.google.com; spf=pass (google.com: domain of 000001375b6836e5-eabe0fd6-f6
+ec-468c-9e77-7269341f59e5-000000@amazonses.com designates 199.255.192.83 as permitted sender) smtp
+.mail=000001375b6836e5-eabe0fd6-f6ec-468c-9e77-7269341f59e5-000000@amazonses.com; dkim=neutral (ba
+d format) header.i=dave@bearpile.com
Return-Path: 000001375b6836e5-eabe0fd6-f6ec-468c-9e77-7269341f59e5-000000@amazonses.com
MIME-Version: 1.0
Content-Transfer-Encoding: binary
Content-Type: multipart/alternative; boundary="_----------=_133726838511930"; charset="iso-8859-1"
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=bearpile.com; h=mime-version:content-transfer-encodin
+g:content-type:to:subject; s=mail; bh=GtAOlzEYoeZMmJtx5u+nHLScQcQ=; b=YtjeJdO05hplgDk1IGqiL5mjDEV0
+YQ5IHzAq3XqtZzlb8/Wg82V0ldTwLaDVr4hd6qKlJRlolF1beDKIiLDyrwHLVDIdlzbNvGDS3h7paIKvnYM+NziY2Qd8ibFdII
+cLUDqkb7Gieq6LeMzQtzMapPcT8GMWJdQhsDmHAOpZvzs=
X-Mailer: MIME::Lite 3.027 (F2.77; T1.28; A2.04; B3.13; Q3.13)
Date: Thu, 17 May 2012 15:26:25 +0000
To: musicstack@gmail.com
Subject: testing DKIM via SES
Message-ID: <000001375b6836e5-eabe0fd6-f6ec-468c-9e77-7269341f59e5-000000@email.amazonses.com>
From: dave@musicstack.com
X-AWS-Outgoing: 199.255.192.83
I have tried it without using sender policy, but i get the same message (dkim=neutral (bad format)
+message.
Though without the sender policy, it seems to include :date in the header, hence why I added a send
+er policy to remove that since it is not advised to have this field in the header.
Can anyone help tell me what I am doing wrong?
My perl code is below:
thank you.
Dave
#!/usr/bin/perl
require "$htdocs/lib/ses.pl";
use Mail::DKIM::Signer;
$to="musicstack\@gmail.com";
$from="dave\@musicstack.com";
$msg = MIME::Lite->new(
To =>"$to",
Subject =>"testing DKIM via SES",
Type =>'multipart/alternative',
);
my $text_part= MIME::Lite->new(
Type =>'text/plain',
Data =>"this is a test",
);
my $html_part= MIME::Lite->new(
Type => 'multipart/related',
);
$html_part->attach (
Type => 'text/html',
Data => "this is a <b>Test</b>",
);
$msg->attach($text_part);
$msg->attach($html_part);
$msg->attr("content-type.charset" => "iso-8859-1");
my $policyfn = sub {
my $dkim = shift;
$dkim->add_signature(
new Mail::DKIM::Signature(
Algorithm => "rsa-sha1",
Method => "relaxed",
Headers => "mime-version:content-transfer-encoding:content-type:to:subject",
Domain => "bearpile.com",
Selector => "mail",
));
return;
};
my $dkim = Mail::DKIM::Signer->new(
Algorithm => "rsa-sha1",
Method => "relaxed",
Domain => "bearpile.com",
Selector => "mail",
Policy => $policyfn,
KeyFile => "/opt/dkim/mail.key.pem"
);
my $raw_data = $msg->as_string;
$raw_data =~ s/\n/\015\012/gs;
$dkim->PRINT($raw_data);
$dkim->CLOSE;
my $sig = $dkim->signature;
my ($header_name, $header_content) = split /:\s*/, $sig->as_string, 2;
unshift @{$msg->{Header}}, [ $header_name, $header_content ];
$raw_msg = $msg->as_string;
&ses_send ($from,$to,$raw_msg,$mail,$aws_credential_file);
|
| Direct Responses: 13725 | Write a response |