msys.validate.opendkim.sign
Name
msys.validate.opendkim.sign — Sign a message using OpenDKIM
Synopsis
msys.validate.opendkim.sign(msg, vctx, options)
msg: userdata, ec_message type vctx: userdata, validate_context type options: table, optional
Description
This function signs a message using a signature generated by OpenDKIM. It requires the opendkim
module.
Enable this function with the statement require('msys.validate.opendkim');
.
It takes the following parameters:
-
msg
– mail message to sign -
vctx
– validation context -
options
– table that allows the caller to override the following options:-
base_domain/signing_domain
– default signing domainThese two parameters are synonyms for one another, each will have the same effect.
-
header_canon
– default header canonicalization setting -
body_canon
– default body canonicalization setting -
digest
– default digest setting -
headerlist
– default list of headers to sign -
identity
– default signing identity -
selector
– default signing selector -
keyfile
– default signing key file, which may be parameterized as defined in “opendkim – Open Source DKIM”) -
keybuf
– default signing keyThis hash entry must contain the PEM encoded private key to use for signing the messages. This must be a contiguous string, with no line breaks and no white space, without the
BEGIN
andEND
tags that are found in the key file itself. The format is similar to the format used to store the public key in the DKIM DNS records. -
body_length_limit
– default body_length_limit setting
-
Note
This function should only be invoked during the core_final_validation hook.
require("msys.core");
require("opendkim.dkim");
require("msys.validate.opendkim");
require("msys.extended.message");
local mod ={};
function mod:core_final_validation(msg, accept, vctx)
local responsible = table.concat(msg:address_header('Sender'), ' ')
if responsible == nil then
responsible = table.concat(msg:address_header('From'), ' ')
end
if (string.find(responsible, 'ectest.example.com', 1)) then
local base_domain = 'ectest.example.com';
local header_canon = 'relaxed';
local body_canon = 'relaxed';
local digest = 'rsa-sha1';
local identity = '\@ectest.example.com';
local selector = 'dkim-s1024';
local key_file = '/opt/msys/ecelerity/etc/conf/default/dk/ectest.example.com/dkim-s1024.key';
local body_length_limit = 0;
local options = {};
options["base_domain"] = base_domain
options["header_canon"] = header_canon
options["body_canon"] = body_canon
options["digest"] = digest
options["selector"] = selector
options["keyfile"] = key_file
options["identity"] = identity
msys.validate.opendkim.sign(msg, vctx, options);
end
return msys.core.VALIDATE_CONT;
end
msys.registerModule("automation", mod);
See Also
msys.validate.opendkim.get_sig_canons, msys.validate.opendkim.verify, msys.validate.opendkim.get_num_sigs, msys.validate.opendkim.get_sig, msys.validate.opendkim.get_sig_domain, msys.validate.opendkim.get_sig_selector, msys.validate.opendkim.get_sig_errorstr, msys.validate.opendkim.get_sig_flags, msys.validate.opendkim.get_sig_identity, msys.validate.opendkim.get_sig_keysize, msys.validate.opendkim.get_sig_signalg, msys.validate.opendkim.get_sig_hdrsigned,