Skip to content

Verification of email with same dsp but multiple keys #267

Description

@BornPsych

In this function,

export async function resolveDNSFromZKEmailArchive(name: string, type: string) {
if (type !== 'TXT') {
throw new Error(`ZK Email Archive only supports TXT records - got ${type}`);
}
// Get domain from full dns record name - $selector._domainkey.$domain.com
const domain = name.split('.').slice(2).join('.');
const selector = name.split('.')[0];
const queryUrl = new URL(ZKEMAIL_DNS_ARCHIVER_API);
queryUrl.searchParams.set('domain', domain);
const resp = await fetch(queryUrl);
const data = await resp.json();
const dkimRecord = data.find((record: any) => record.selector === selector);
if (!dkimRecord) {
throw new CustomError(
`DKIM record not found for domain ${domain} and selector ${selector} in ZK Email Archive.`,
'ENODATA',
);
}
return [dkimRecord.value];
}

We are currently using the function below, which fetches the DKIM key using the domain and checks only the first selector that matches the domain-selector.

However, in our case, a single DSP can be associated with multiple DKIM keys. So instead of validating the email using just the first key, we need to verify it against all keys that share the same DSP. and we have to make sure verification is happening with all the keys, and if it don't find any suitable key, it should return the bad signature error

const dkimRecord = data.find((record: any) => record.selector === selector);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions