-
Notifications
You must be signed in to change notification settings - Fork 3
opendkim.sig_getselector()
Christopher Mooney edited this page Feb 12, 2018
·
2 revisions
This call retrieves the selector from the signature ultimately used to verify a message. This can be called after opendkim.eoh()
. This function uses the signature handle found by opendkim.get_signature()
to pull the selector from. Internally, this function calls opendkim.get_signature()
, so there is no need to explicitly call it yourself.
Type: undefined
- throws an error if
- The function was called before
opendkim.eoh()
and thusopendkim.verify()
- The function was called before
- returns the identity string on success, or empty string if there isn't one.
- 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();
var selector = opendkim.sig_getselector();
console.log('selector: ' + selector);
} 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();
var selector = opendkim.sig_getselector();
console.log('selector: ' + selector);
} catch (err) {
console.log(opendkim.sig_geterrorstr(opendkim.sig_geterror()));
console.log(err);
}
}
const OpenDKIM = require('node-opendkim');
function verify(opendkim, message, callback) {
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) {
return callback(err, result);
}
var selector = opendkim.sig_getselector();
return callback(err, selector);
});
});
});
}
var opendkim = new OpenDKIM();
verify(opendkim, message, function (err, selector) {
if (err) {
return console.log(opendkim.sig_geterrorstr(opendkim.sig_geterror()));
}
// success
console.log('selector: ' + selector);
});