October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

Verify a DNS TXT Challenge in Node.js—and Know What It Proves

Learn to check DNS TXT challenges with Node.js, distinguish lookup failures from missing values, and understand the limited proof a DNS-01 match provides.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To check a DNS TXT challenge in Node.js, call dnsPromises.resolveTxt() from node:dns/promises, join the chunks returned for each individual TXT record, and compare each complete record with the expected value. For ACME DNS-01, query _acme-challenge.<domain>. A match shows that the expected challenge value was visible through DNS for that validation name at the time of the lookup; it does not establish legal ownership or identify the person or organization controlling the domain.

Check a TXT record in Node.js

The promises API returns a two-dimensional array: each inner array contains the text chunks for one TXT record. Join chunks within each inner array before comparing it with the expected value. Do not join all returned strings together, because that could combine separate records.

As an Amazon Associate I earn from qualifying purchases.

import dns from 'node:dns/promises';

export async function hasTxtValue(hostname, expectedValue) {
  const records = await dns.resolveTxt(hostname);
  return records.some((chunks) => chunks.join('') === expectedValue);
}

const hostname = `_acme-challenge.${domain}`;
const verified = await hasTxtValue(hostname, expectedChallengeValue);

This is an illustrative pattern, not a tested implementation. Define separately how your application handles timeouts, retries, cancellation, logging, and multiple matching or unrelated TXT records. The API was added in Node.js v10.6.0; the current documentation cited here is for Node.js v26.8.2. Node.js DNS documentation

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What ACME DNS-01 verifies

ACME DNS-01 asks a client to publish a designated TXT value under a validation name formed by prepending _acme-challenge to the domain identifier. The challenge uses a random token with at least 128 bits of entropy; the client combines it with its account key to form a key authorization, computes a SHA-256 digest, and publishes the base64url-encoded digest as the TXT value. IETF RFC 8555

In practical terms, a matching value demonstrates that the challenge response could be provisioned and observed through DNS for the relevant name. It is a test of control over that DNS validation path—not proof of legal title, organizational identity, or control of every service associated with the domain. Japan Registry Services describes DNS ownership/control checks as a challenge-response process: a service provider issues a one-time secret, the subscriber publishes it in authoritative DNS, and the provider queries DNS to verify it. Japan Registry Services, “Important Notes of Using Domain Name Ownership / Control Verification by DNS”

DNS-01 tests the ability to publish a DNS record. ACME’s HTTP-01 method instead tests whether a client can provision a file at a specified path on a server accessible under the domain. These are different control surfaces; DNS-01 is not universally preferable. RFC 8555

Separate a failed lookup from a failed match

Verification code should distinguish a DNS query error from a successful query that returns no matching record. With resolveTxt(), lookup failures reject the promise; a completed lookup returns the TXT records it found. Treat these as distinct outcomes:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Lookup failed: DNS did not return a usable result to this query. Report or handle the error; do not call it a completed negative verification.
  • Lookup succeeded, value absent: Records were returned, but none matched the expected complete challenge value.
  • Lookup succeeded, value present: At least one complete TXT record matched the expected value.

In particular, Node.js documents that ENOTFOUND can arise from lookup failures other than a nonexistent name, including unavailable file descriptors. It is not conclusive evidence that the hostname does not exist. Node.js DNS documentation

DNS visibility can change as records are published and observed by resolvers. If your workflow expects a record to appear after provisioning, use bounded polling suited to your DNS provider and application. The cited standards do not prescribe a universal propagation delay or polling interval, so avoid reporting a fixed wait as a protocol requirement or declaring lack of control from one unsuccessful lookup.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Harden the issuance process around the TXT check

Use DNSSEC validation where appropriate

Japan Registry Services recommends that service providers enable DNSSEC validation on the full-service resolvers used for verification, and that subscribers deploy DNSSEC on authoritative DNS servers. These measures address the integrity of DNS data in the verification path; they do not change how Node.js represents TXT records. Japan Registry Services

Use CAA for certificate-issuance policy

CAA is separate from the challenge token. It lets a domain owner specify which certificate authorities may issue certificates for names in public DNS. Let’s Encrypt documents its CAA identifier as letsencrypt.org; its documentation notes that, by default, any public CA may issue if it validates control. The issue property governs ordinary and wildcard issuance unless a separate issuewild record changes wildcard handling. Let’s Encrypt CAA documentation

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Let’s Encrypt also documents optional validationmethods and accounturi parameters. The former can restrict accepted validation methods, including http-01, dns-01, and tls-alpn-01; the latter can constrain issuance to an ACME account. CAA records with the same property type are additive: if any one allows issuance, it is allowed. CAA therefore governs issuance authorization; it neither supplies the TXT challenge value nor performs the Node.js TXT lookup. Let’s Encrypt CAA documentation

Choose a validation method based on the available control surface

  • DNS access: Can your process publish the required TXT record, manually or through a safe DNS-provider API?
  • HTTP access: Can it serve the challenge file at the required path under the domain?
  • TLS-ALPN access: Can the deployment configure the relevant TLS challenge method if the CA and client support it?
  • Wildcard requirement: Confirm the current requirements of the certificate authority and ACME client you use before choosing a method.
  • Operations and policy: Consider how you will observe and recover from DNS visibility or HTTP-serving failures, and whether CAA should limit the issuing CA, validation method, or ACME account.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.