-
Notifications
You must be signed in to change notification settings - Fork 3
opendkim.eoh()
Christopher Mooney edited this page Feb 12, 2018
·
3 revisions
Denote end-of-headers for a message. opendkim.eoh()
is called when the delimiter between the message's headers and its body is encountered. That is, when one is done processing the header section.
For more information:
http://www.opendkim.org/libopendkim/dkim_eoh.html
Type: undefined
- On failure, an exception is thrown that indicates the cause of the problem.
- This function may throw
DKIM_STAT_NOSIG
when verifying if no signature was present in the message headers. This is simply advisory; you must continue executing down to theopendkim.eom()
call to determine whether or not a signature should have been present. - This function can throw
DKIM_STAT_SYNTAX
when verifying if a header that must be signed was not included in a received signature, or if the message appeared to contain no sender header field. In the latter case, the dkim handle is rendered unusable by future calls toopendkim.body()
oropendkim.eom()
. - This function can throw
DKIM_STAT_CANTVRFY
when verifying if all discovered signatures were either marked to be ignored, contained syntax errors, or failed verification attempts. This is only tested if theDKIM_LIBFLAG_EOHCHECK
library flag is set. - This function can throw
DKIM_STAT_SYNTAX
in either mode if the input message does not conform to the header field count checks imposed by theDKIM_LIBFLAG_STRICTHDRS
library flag. - This function can throw
DKIM_STAT_NORESOURCE
for a verifying handle if an attempt to construct a DNS query based on the selector and domain in a signature exceeded the maximum allowable query size.
const OpenDKIM = require('node-opendkim');
async function verify(header, body) {
var opendkim = new OpenDKIM();
try {
await opendkim.verify({id: undefined});
await opendkim.header({
header: header,
length: header.length
});
await opendkim.eoh();
await opendkim.body({
body: body,
length: body.length
});
await opendkim.eom();
} catch (err) {
console.log(opendkim.sig_geterrorstr(opendkim.sig_geterror()));
console.log(err);
}
}
const OpenDKIM = require('node-opendkim');
function verify_sync(header, body) {
var opendkim = new OpenDKIM();
try {
opendkim.verify_sync({id: undefined});
opendkim.header_sync({
header: header,
length: header.length
});
opendkim.eoh_sync();
opendkim.body_sync({
body: body,
length: body.length
});
opendkim.eom_sync();
} catch (err) {
console.log(opendkim.sig_geterrorstr(opendkim.sig_geterror()));
console.log(err);
}
}
const OpenDKIM = require('node-opendkim');
function verify(opendkim, header, body, callback) {
opendkim.verify({id: undefined}, function (err, result) {
if (err) {
return callback(err, result);
}
var header_obj = {
header: header,
length: header.length
};
opendkim.header(header_obj, function (err, result) {
if (err) {
return callback(err, result);
}
opendkim.eoh(function (err, result) {
if (err) {
return callback(err, result);
}
var body_obj = {
body: body,
length: body.length
};
opendkim.body(body_obj, function (err, result) {
if (err) {
return callback(err, result);
}
opendkim.eom(function (err, result) {
if (err) {
return callback(err, result);
}
return callback(err, result);
});
});
});
});
}
var opendkim = new OpenDKIM();
verify(opendkim, header, body, function (err, result) {
if (err) {
return console.log(opendkim.sig_geterrorstr(opendkim.sig_geterror()));
}
// success
});