-
Notifications
You must be signed in to change notification settings - Fork 3
opendkim.get_signature()
Christopher Mooney edited this page Feb 9, 2018
·
3 revisions
This call retrieves the signature ultimately used to verify a message. This must be called after either opendkim.chunk_end()
or opendkim.eom()
, and all it does is set the internal sig handle with either the first signature found to be valid that was not flagged to be ignored by the caller, or if none were valid, the first signature not flagged to be ignored by the caller.
Type: undefined
- throws an error if
- The function was called before
opendkim.chunk_end()
oropendkim.eom()
and thusopendkim.verify()
- The message represented was not signed.
- The function was called before
- returns
self
if the internal signature handle is set, thus allowing interrogation of the signature.
- throws an error if there is simply no signature on the message.
const OpenDKIM = require('node-opendkim');
async function verify(message) {
var opendkim = new OpenDKIM();
try {
await opendkim.verify({id: undefined});
await opendkim.chunk({
message: message,
length: message.length
});
await opendkim.chunk_end();
opendkim.get_signature();
} catch (err) {
console.log(opendkim.sig_geterrorstr(opendkim.sig_geterror()););
console.log(err);
}
}
const OpenDKIM = require('node-opendkim');
function verify_sync(message) {
var opendkim = new OpenDKIM();
try {
opendkim.verify_sync({id: undefined});
opendkim.chunk_sync({
message: message,
length: message.length
});
opendkim.chunk_end_sync();
opendkim.get_signature();
} catch (err) {
console.log(opendkim.sig_geterrorstr(opendkim.sig_geterror()););
console.log(err);
}
}
const OpenDKIM = require('node-opendkim');
function verify(message, callback) {
var opendkim = new OpenDKIM();
opendkim.verify({id: undefined}, function (err, result) {
if (err) {
return callback(err, result);
}
var options = {
message: message,
length: message.length
};
opendkim.chunk(options, function (err, result) {
if (err) {
return callback(err, result);
}
opendkim.chunk_end(function (err, result) {
if (err) {
console.log(opendkim.sig_geterrorstr(opendkim.sig_geterror()););
return callback(err, result);
}
opendkim.get_signature();
return callback(err, result);
});
});
});
}
verify(message, function (err, result) {
if (err) {
// handle error
console.log(err);
return;
}
// success
});