Merge branch 'master' into 4.next
[exim.git] / test / aux-fixed / dkim / sign.pl
CommitLineData
6a11a9e6
JH
1use Mail::DKIM::Signer;
2use Mail::DKIM::TextWrap; #recommended
3use Getopt::Long;
4
abe1010c 5# default option values
6a11a9e6 6my $method = "simple/simple";
abe1010c
JH
7my $selector = "sel";
8my $keyfile = "aux-fixed/dkim/dkim.private";
2592e6c0 9my $algorithm = "rsa-sha1";
6a11a9e6
JH
10
11GetOptions(
12 "method=s" => \$method,
abe1010c
JH
13 "selector=s" => \$selector,
14 "keyfile=s" => \$keyfile,
2592e6c0 15 "algorithm=s" => \$algorithm,
6a11a9e6
JH
16);
17
18# create a signer object
19my $dkim = Mail::DKIM::Signer->new(
2592e6c0 20 Algorithm => $algorithm,
6a11a9e6
JH
21 Method => $method,
22 Domain => "test.ex",
abe1010c
JH
23 Selector => $selector,
24 KeyFile => $keyfile,
6a11a9e6
JH
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";