src/verify.js
async function verifyDnsChallenge(authz, challenge, keyAuthorization, prefix = '_acme-challenge.') {
    debug(`Resolving DNS TXT records for ${authz.identifier.value}, prefix: ${prefix}`);
    let challengeRecord = `${prefix}${authz.identifier.value}`;

    try {
        /* Attempt CNAME record first */
        debug(`Checking CNAME for record ${challengeRecord}`);
        const cnameRecords = await dns.resolveCnameAsync(challengeRecord);

        if (cnameRecords.length) {
            debug(`CNAME found at ${challengeRecord}, new challenge record: ${cnameRecords[0]}`);
            challengeRecord = cnameRecords[0];
        }
    }
    catch (e) {
        debug(`No CNAME found for record ${challengeRecord}`);
    }

    /* Read TXT record */
    const result = await dns.resolveTxtAsync(challengeRecord);
    const records = [].concat(...result);

    debug(`Query successful, found ${records.length} DNS TXT records`);

    if (records.indexOf(keyAuthorization) === -1) {
        throw new Error(`Authorization not found in DNS TXT records for ${authz.identifier.value}`);
    }

    debug(`Key authorization match for ${challenge.type}/${authz.identifier.value}, ACME challenge verified`);
    return true;
}
async function verifyDnsChallenge(authz, challenge, keyAuthorization, prefix = '_acme-challenge.') {
    debug(`Resolving DNS TXT records for ${authz.identifier.value}, prefix: ${prefix}`);
    let challengeRecord = `${prefix}${authz.identifier.value}`;

    try {
        /* Attempt CNAME record first */
        debug(`Checking CNAME for record ${challengeRecord}`);
        const cnameRecords = await dns.resolveCnameAsync(challengeRecord);

        if (cnameRecords.length) {
            debug(`CNAME found at ${challengeRecord}, new challenge record: ${cnameRecords[0]}`);
            challengeRecord = cnameRecords[0];
        }
    }
    catch (e) {
        debug(`No CNAME found for record ${challengeRecord}`);
    }

    /* Read TXT record */
    const result = await dns.resolveTxtAsync(challengeRecord);
    const records = [].concat(...result);

    debug(`Query successful, found ${records.length} DNS TXT records`);

    if (records.indexOf(keyAuthorization) === -1) {
        throw new Error(`Authorization not found in DNS TXT records for ${authz.identifier.value}`);
    }

    debug(`Key authorization match for ${challenge.type}/${authz.identifier.value}, ACME challenge verified`);
    return true;
}
async function verifyDnsChallenge ( authz , challenge , keyAuthorization , prefix = '_acme-challenge.' ) { debug ( ` ${ authz . identifier . value } ${ prefix } ` ) ; let challengeRecord = ` ${ prefix } ${ authz . identifier . value } ` ; try { /* Attempt CNAME record first */ debug ( ` ${ challengeRecord } ` ) ; const cnameRecords = await dns . resolveCnameAsync ( challengeRecord ) ; if ( cnameRecords . length ) { debug ( ` ${ challengeRecord } ${ cnameRecords [ 0 ] } ` ) ; challengeRecord = cnameRecords [ 0 ] ; } } catch ( e ) { debug ( ` ${ challengeRecord } ` ) ; } /* Read TXT record */ const result = await dns . resolveTxtAsync ( challengeRecord ) ; const records = [ ] . concat ( ... result ) ; debug ( ` ${ records . length } ` ) ; if ( records . indexOf ( keyAuthorization ) === - 1 ) { throw new Error ( ` ${ authz . identifier . value } ` ) ; } debug ( ` ${ challenge . type } ${ authz . identifier . value } ` ) ; return true ; }
Verify ACME DNS challenge

https://github.com/ietf-wg-acme/acme/blob/master/draft-ietf-acme-acme.md#dns-challenge

@param {object} authz Identifier authorization
@param {object} challenge Authorization challenge
@param {string} keyAuthorization Challenge key authorization
@param {string} [prefix] DNS prefix
@returns {Promise<boolean>}
Verify ACME DNS challenge