Merge branch 'master' into 4.next
[exim.git] / test / aux-fixed / dkim / sign.pl
... / ...
CommitLineData
1use Mail::DKIM::Signer;
2use Mail::DKIM::TextWrap; #recommended
3use Getopt::Long;
4
5# default option values
6my $method = "simple/simple";
7my $selector = "sel";
8my $keyfile = "aux-fixed/dkim/dkim.private";
9my $algorithm = "rsa-sha1";
10
11GetOptions(
12 "method=s" => \$method,
13 "selector=s" => \$selector,
14 "keyfile=s" => \$keyfile,
15 "algorithm=s" => \$algorithm,
16);
17
18# create a signer object
19my $dkim = Mail::DKIM::Signer->new(
20 Algorithm => $algorithm,
21 Method => $method,
22 Domain => "test.ex",
23 Selector => $selector,
24 KeyFile => $keyfile,
25 );
26
27# read an email and pass it into the signer, one line at a time
28while (<STDIN>)
29{
30 # remove local line terminators
31 chomp;
32 s/\015$//;
33
34 # use SMTP line terminators
35 $dkim->PRINT("$_\015\012");
36}
37$dkim->CLOSE;
38
39# what is the signature result?
40my $signature = $dkim->signature;
41print $signature->as_string;
42print "\n";
43
44#print $dkim->headers;
45#print "\n";