ARC: add independent-source testcase. Fix signatures by not line-terminating
[exim.git] / test / aux-fixed / dkim / sign_arc.pl
CommitLineData
d64f2515
JH
1use Mail::DKIM::ARC::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-sha256";
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 $signer = Mail::DKIM::ARC::Signer->new(
20 Algorithm => $algorithm,
21 Chain => 'none', # or pass|fail|ar
22 Domain => 'test.ex',
23 SrvId => 'test.ex',
24 Selector => $selector,
25 KeyFile => $keyfile,
26 Headers => 'x-header:x-header2',
27 );
28
29
30 # NOTE: any email being ARC signed must have an Authentication-Results
31 # header so that the ARC seal can cover those results copied into
32 # an ARC-Authentication-Results header.
33
34# read an email and pass it into the signer, one line at a time
35while (<STDIN>)
36{
37 # remove local line terminators
38 chomp;
39 s/\015$//;
40
41 # use SMTP line terminators
42 $signer->PRINT("$_\015\012");
43}
44$signer->CLOSE;
45
46die 'Failed' . $signer->result_details() unless $signer->result() eq 'sealed';
47
48# Get all the signature headers to prepend to the message
49# ARC-Seal, ARC-Message-Signature and ARC-Authentication-Results
50# in that order.
51print $signer->as_string;