From 08d2e88c0afd301bf120d048452098552f0b1888 Mon Sep 17 00:00:00 2001 From: Danny Sonnenschein Date: Fri, 2 Oct 2020 18:05:28 +0200 Subject: [PATCH] Added support for resolving DNS CAA records This adds support for DNS Certification Authority Authorization (RFC 6844) to nodejs. This closes #19239 and possibly affects #14713. --- doc/api/dns.md | 17 +++++++ lib/dns.js | 1 + lib/internal/dns/promises.js | 1 + lib/internal/dns/utils.js | 1 + src/cares_wrap.cc | 68 ++++++++++++++++++++++++++ src/env.h | 2 + test/common/internet.js | 2 + test/internet/test-dns.js | 41 ++++++++++++++++ test/internet/test-trace-events-dns.js | 1 + 9 files changed, 134 insertions(+) diff --git a/doc/api/dns.md b/doc/api/dns.md index e5ad6544a98599..c41fb44b4bd77b 100644 --- a/doc/api/dns.md +++ b/doc/api/dns.md @@ -81,6 +81,7 @@ The following methods from the `dns` module are available: * [`resolver.resolve4()`][`dns.resolve4()`] * [`resolver.resolve6()`][`dns.resolve6()`] * [`resolver.resolveAny()`][`dns.resolveAny()`] +* [`resolver.resolveCaa()`][`dns.resolveCaa()`] * [`resolver.resolveCname()`][`dns.resolveCname()`] * [`resolver.resolveMx()`][`dns.resolveMx()`] * [`resolver.resolveNaptr()`][`dns.resolveNaptr()`] @@ -290,6 +291,7 @@ records. The type and structure of individual results varies based on `rrtype`: | `'AAAA'` | IPv6 addresses | {string} | [`dns.resolve6()`][] | | `'ANY'` | any records | {Object} | [`dns.resolveAny()`][] | | `'CNAME'` | canonical name records | {string} | [`dns.resolveCname()`][] | +| `'CAA'` | CA authorization | {Object} | [`dns.resolveCaa()`][] | | `'MX'` | mail exchange records | {Object} | [`dns.resolveMx()`][] | | `'NAPTR'` | name authority pointer records | {Object} | [`dns.resolveNaptr()`][] | | `'NS'` | name server records | {string} | [`dns.resolveNs()`][] | @@ -414,6 +416,21 @@ Uses the DNS protocol to resolve `CNAME` records for the `hostname`. The will contain an array of canonical name records available for the `hostname` (e.g. `['bar.example.com']`). +## `dns.resolveCaa(hostname, callback)` + + +* `hostname` {string} +* `callback` {Function} + * `err` {Error} + * `records` {object[]} + +Uses the DNS protocol to resolve `CAA` records for the `hostname`. The +`addresses` argument passed to the `callback` function +will contain an array of certification authority authorization records +available for the `hostname` (e.g. `[{critial: 0, iodef: 'letsencrypt.org']`). + ## `dns.resolveMx(hostname, callback)`