.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Mail::DKIM::ARC::Signer 3pm" .TH Mail::DKIM::ARC::Signer 3pm "2020-09-11" "perl v5.30.3" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Mail::DKIM::ARC::Signer \- generates a DKIM signature for a message .SH "VERSION" .IX Header "VERSION" version 1.20200907 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& use Mail::DKIM::ARC::Signer; \& use Mail::DKIM::TextWrap; #recommended \& \& # create a signer object \& my $signer = Mail::DKIM::ARC::Signer\->new( \& Algorithm => \*(Aqrsa\-sha256\*(Aq, \& Chain => \*(Aqnone\*(Aq, # or pass|fail|ar \& Domain => \*(Aqexample.org\*(Aq, \& SrvId => \*(Aqexample.org\*(Aq, \& Selector => \*(Aqselector1\*(Aq, \& KeyFile => \*(Aqprivate.key\*(Aq, \& Headers => \*(Aqx\-header:x\-header2\*(Aq, \& ); \& \& # read an email from a file handle \& $signer\->load(*STDIN); \& \& # NOTE: any email being ARC signed must have an Authentication\-Results \& # header so that the ARC seal can cover those results copied into \& # an ARC\-Authentication\-Results header. \& \& # or read an email and pass it into the signer, one line at a time \& while () \& { \& # remove local line terminators \& chomp; \& s/\e015$//; \& \& # use SMTP line terminators \& $signer\->PRINT("$_\e015\e012"); \& } \& $signer\->CLOSE; \& \& die \*(AqFailed\*(Aq $signer\->result_details() unless $signer\->result() eq \*(Aqsealed\*(Aq; \& \& # Get all the signature headers to prepend to the message \& # ARC\-Seal, ARC\-Message\-Signature and ARC\-Authentication\-Results \& # in that order. \& print $signer\->as_string; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This class is the part of Mail::DKIM responsible for generating \&\s-1ARC\s0 Seals for a given message. You create an object of this class, specifying the parameters for the ARC-Message-Signature you wish to create. .PP You also need to pass the 'Chain' value (pass or fail) from validation of the previous ARC-Seals on the message. .PP Next, you feed it the entire message using \*(L"\s-1\fBPRINT\s0()\fR\*(R", completing with \*(L"\s-1\fBCLOSE\s0()\fR\*(R". .PP Finally, use the \*(L"\fBas_string()\fR\*(R" method to get the new \s-1ARC\s0 headers. .PP Note: you can only seal a message which has already had an Authentication-Results header added, either by using \*(L"\s-1\fBPRINT\s0()\fR\*(R" to pre-feed it into this module, or by adding a message which has already been authenticated by your inbound scanning mechanisms. .PP It is not necessary to ARC-Seal a message which already has \s-1DKIM\s0 signatures if you are not modifying the message and hence breaking the existing DKIM-Signature or top ARC-Message-Signature on the email. .SS "Pretty Signatures" .IX Subsection "Pretty Signatures" Mail::DKIM includes a signature-wrapping module (which inserts linebreaks into the generated signature so that it looks nicer in the resulting message. To enable this module, simply call .PP .Vb 1 \& use Mail::DKIM::TextWrap; .Ve .PP in your program before generating the signature. .SH "CONSTRUCTOR" .IX Header "CONSTRUCTOR" .SS "\fBnew()\fP" .IX Subsection "new()" Construct an object-oriented signer. .PP .Vb 10 \& # create a signer using the default policy \& my $signer = Mail::DKIM::ARC::Signer\->new( \& Algorithm => \*(Aqrsa\-sha256\*(Aq, \& Chain => \*(Aqnone\*(Aq, # or pass|fail|ar \& Domain => \*(Aqexample.org\*(Aq, \& SrvId => \*(Aqexample.org\*(Aq, \& Selector => \*(Aqselector1\*(Aq, \& KeyFile => \*(Aqprivate.key\*(Aq, \& Headers => \*(Aqx\-header:x\-header2\*(Aq, \& ); .Ve .IP "Key" 4 .IX Item "Key" rather than using \f(CW\*(C`KeyFile\*(C'\fR, use \f(CW\*(C`Key\*(C'\fR to use an already-loaded Mail::DKIM::PrivateKey object. .IP "Chain" 4 .IX Item "Chain" The cv= value for the Arc-Seal header. \*(L"ar\*(R" means to copy it from an Authentication-Results header, or use none if there isn't one. .IP "SrvId" 4 .IX Item "SrvId" The authserv-id in the Authentication-Results headers, defaults to Domain. .IP "Headers" 4 .IX Item "Headers" A colon separated list of headers to sign, this is added to the list of default headers as shown in in the \s-1DKIM\s0 specification. .Sp For each specified header all headers of that type which are present in the message will be signed, but we will not oversign or sign headers which are not present. .Sp If you require greater control over signed headers please use the \fBextended_headers()\fR method instead. .Sp The list of headers signed by default is as follows .Sp .Vb 8 \& From Sender Reply\-To Subject Date \& Message\-ID To Cc MIME\-Version \& Content\-Type Content\-Transfer\-Encoding Content\-ID Content\-Description \& Resent\-Date Resent\-From Resent\-Sender Resent\-To Resent\-cc \& Resent\-Message\-ID \& In\-Reply\-To References \& List\-Id List\-Help List\-Unsubscribe List\-Subscribe \& List\-Post List\-Owner List\-Archive .Ve .SH "METHODS" .IX Header "METHODS" .SS "\s-1\fBPRINT\s0()\fP" .IX Subsection "PRINT()" Feed part of the message to the signer. .PP .Vb 1 \& $signer\->PRINT("a line of the message\e015\e012"); .Ve .PP Feeds content of the message being signed into the signer. The \s-1API\s0 is designed this way so that the entire message does \s-1NOT\s0 need to be read into memory at once. .PP Please note that although the \s-1\fBPRINT\s0()\fR method expects you to use SMTP-style line termination characters, you should \s-1NOT\s0 use the SMTP-style dot-stuffing technique described in \s-1RFC 2821\s0 section 4.5.2. Nor should you use a <\s-1CR\s0><\s-1LF\s0>.<\s-1CR\s0><\s-1LF\s0> sequence to terminate the message. .SS "\s-1\fBCLOSE\s0()\fP" .IX Subsection "CLOSE()" Call this when finished feeding in the message. .PP .Vb 1 \& $signer\->CLOSE; .Ve .PP This method finishes the canonicalization process, computes a hash, and generates a signature. .SS "\fBextended_headers()\fP" .IX Subsection "extended_headers()" This method overrides the headers to be signed and allows more control than is possible with the Headers property in the constructor. .PP The method expects a HashRef to be passed in. .PP The Keys are the headers to sign, and the values are either the number of headers of that type to sign, or the special values \&'*' and '+'. .PP * will sign \s-1ALL\s0 headers of that type present in the message. .PP + will sign \s-1ALL + 1\s0 headers of that type present in the message to prevent additional headers being added. .PP You may override any of the default headers by including them in the hashref, and disable them by giving them a 0 value. .PP Keys are case insensitive with the values being added upto the highest value. .PP .Vb 6 \& Headers => { \& \*(AqX\-test\*(Aq => \*(Aq*\*(Aq, \& \*(Aqx\-test\*(Aq => \*(Aq1\*(Aq, \& \*(AqSubject\*(Aq => \*(Aq+\*(Aq, \& \*(AqSender\*(Aq => 0, \& }, .Ve .SS "\fBadd_signature()\fP" .IX Subsection "add_signature()" Used by signer policy to create a new signature. .PP .Vb 1 \& $signer\->add_signature(new Mail::DKIM::Signature(...)); .Ve .PP Signer policies can use this method to specify complete parameters for the signature to add, including what type of signature. For more information, see Mail::DKIM::SignerPolicy. .SS "\fBalgorithm()\fP" .IX Subsection "algorithm()" Get or set the selected algorithm. .PP .Vb 1 \& $alg = $signer\->algorithm; \& \& $signer\->algorithm(\*(Aqrsa\-sha256\*(Aq); .Ve .SS "\fBdomain()\fP" .IX Subsection "domain()" Get or set the selected domain. .PP .Vb 1 \& $alg = $signer\->domain; \& \& $signer\->domain(\*(Aqexample.org\*(Aq); .Ve .SS "\fBload()\fP" .IX Subsection "load()" Load the entire message from a file handle. .PP .Vb 1 \& $signer\->load($file_handle); .Ve .PP Reads a complete message from the designated file handle, feeding it into the signer. The message must use <\s-1CRLF\s0> line terminators (same as the \s-1SMTP\s0 protocol). .SS "\fBheaders()\fP" .IX Subsection "headers()" Determine which headers to put in signature. .PP .Vb 1 \& my $headers = $signer\->headers; .Ve .PP This is a string containing the names of the header fields that will be signed, separated by colons. .SS "\fBkey()\fP" .IX Subsection "key()" Get or set the private key object. .PP .Vb 1 \& my $key = $signer\->key; \& \& $signer\->key(Mail::DKIM::PrivateKey\->load(File => \*(Aqprivate.key\*(Aq)); .Ve .PP The key object can be any object that implements the \&\fBsign_digest()\fR method. (Providing your own object can be useful if your actual keys are stored out-of-process.) .PP If you use this method to specify a private key, do not use \*(L"\fBkey_file()\fR\*(R". .SS "\fBkey_file()\fP" .IX Subsection "key_file()" Get or set the filename containing the private key. .PP .Vb 1 \& my $filename = $signer\->key_file; \& \& $signer\->key_file(\*(Aqprivate.key\*(Aq); .Ve .PP If you use this method to specify a private key file, do not use \*(L"\fBkey()\fR\*(R". .SS "\fBmessage_originator()\fP" .IX Subsection "message_originator()" Access the \*(L"From\*(R" header. .PP .Vb 1 \& my $address = $signer\->message_originator; .Ve .PP Returns the \*(L"originator address\*(R" found in the message, as a Mail::Address object. This is typically the (first) name and email address found in the From: header. If there is no From: header, then an empty Mail::Address object is returned. .PP To get just the email address part, do: .PP .Vb 1 \& my $email = $signer\->message_originator\->address; .Ve .PP See also \*(L"\fBmessage_sender()\fR\*(R". .SS "\fBmessage_sender()\fP" .IX Subsection "message_sender()" Access the \*(L"From\*(R" or \*(L"Sender\*(R" header. .PP .Vb 1 \& my $address = $dkim\->message_sender; .Ve .PP Returns the \*(L"sender\*(R" found in the message, as a Mail::Address object. This is typically the (first) name and email address found in the Sender: header. If there is no Sender: header, it is the first name and email address in the From: header. If neither header is present, then an empty Mail::Address object is returned. .PP To get just the email address part, do: .PP .Vb 1 \& my $email = $dkim\->message_sender\->address; .Ve .PP The \*(L"sender\*(R" is the mailbox of the agent responsible for the actual transmission of the message. For example, if a secretary were to send a message for another person, the \*(L"sender\*(R" would be the secretary and the \*(L"originator\*(R" would be the actual author. .SS "\fBselector()\fP" .IX Subsection "selector()" Get or set the current key selector. .PP .Vb 1 \& $alg = $dkim\->selector; \& \& $dkim\->selector(\*(Aqalpha\*(Aq); .Ve .SS "\fBsignatures()\fP" .IX Subsection "signatures()" Access list of generated signature objects. .PP .Vb 1 \& my @signatures = $dkim\->signatures; .Ve .PP Returns all generated signatures, as a list. .SS "\fBas_string()\fP" .IX Subsection "as_string()" Returns the new \s-1ARC\s0 headers .PP .Vb 1 \& my $pre_headers = $signer\->as_string(); .Ve .PP The headers are separated by \e015\e012 (\s-1SMTP\s0 line separator) including a trailing separator, so can be directly injected in front of the raw message. .SS "\fBas_strings()\fP" .IX Subsection "as_strings()" Returns the new \s-1ARC\s0 headers .PP .Vb 1 \& my @pre_headers = $signer\->as_string(); .Ve .PP The headers are returned as a list so you can add whatever line ending your local \s-1MTA\s0 prefers. .SH "AUTHORS" .IX Header "AUTHORS" .IP "\(bu" 4 Jason Long .IP "\(bu" 4 Marc Bradshaw .IP "\(bu" 4 Bron Gondwana (\s-1ARC\s0) .SH "THANKS" .IX Header "THANKS" Work on ensuring that this module passes the \s-1ARC\s0 test suite was generously sponsored by Valimail (https://www.valimail.com/) .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" .IP "\(bu" 4 Copyright (C) 2013 by Messiah College .IP "\(bu" 4 Copyright (C) 2010 by Jason Long .IP "\(bu" 4 Copyright (C) 2017 by Standcore \s-1LLC\s0 .IP "\(bu" 4 Copyright (C) 2020 by FastMail Pty Ltd .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.