erldns_dnssec behaviour (erldns v13.0.0)
View SourceDNSSEC implementation.
If you want to enable DNSSEC, you need to add this module to the packet pipeline after a resolver,
that being an authoritative (e.g. erldns_resolver) or recursive
(e.g. erldns_resolver_recursive).
You also need to provide the zone keys for signing, during loading,
see ZONES for more details.
Configuration
{erldns, [
{dnssec, #{
authenticated_data => false %% Set AD on answers from signed zones (default: false)
}}
]}RFC 4035 §3.1.6 lets an authoritative server set AD only when explicitly configured to, and only for zones it obtained by secure means: enable it only if zones reach erldns over an authenticated channel.
Delegation points
The resolver puts the delegation a response refers to in the pipeline opts as zonecut
(see erldns_resolver), and a referral is completed as RFC 4035 §3.1.4 requires: the authority
section carries the delegation's DS RRset and its RRSIG, or an NSEC at the delegation name proving
there is none. NS RRsets at delegation points, glue, and records occluded by a cut are never signed
(§2.2), and an NSEC at a delegation name advertises only NS, DS, RRSIG and NSEC (RFC 4034 §4.1.2).
NSEC type-mapper extension
When a name only carries a custom type (e.g. a record that another pipeline stage synthesizes into A/CNAME at query time), the authenticated-denial NSEC record for that name must still advertise the standard types the client will actually receive, or validating resolvers reject the answer. A mapper widens the NSEC type bitmap accordingly.
A mapper is a fun((RecordType, QType) -> [Type]) implementing the nsec_rr_type_mapper/2
callback. To register one, the owning pipeline stage calls add_nsec_type_mapper/3 from its own
erldns_pipeline:prepare/1:
prepare(Opts) ->
erldns_dnssec:add_nsec_type_mapper(Opts, [?CUSTOM_TYPE], fun ?MODULE:nsec_rr_type_mapper/2).
Summary
Callbacks
NSEC type-mapper extension callback.
Functions
Register an NSEC type mapper for the given record types into the pipeline opts.
erldns_pipeline:call/2 callback.
erldns_pipeline:deps/0 callback.
Get signed records from a zone.
Get the records of a zone signed with the zone signing key.
erldns_pipeline:prepare/1 callback.
Given a zone and a set of records, return the RRSIG records.
Types
-type nsec_type_mappers() :: #{dns:type() => nsec_type_mapper_fun()}.
Callbacks
NSEC type-mapper extension callback.
Pipeline stages that introduce custom record types (e.g. ALIAS) implement this to widen the NSEC
type bitmap: given a record type present at a name and the query type, return the standard DNS types
the custom type should be advertised as. The mapper is registered into the pipeline opts with
add_nsec_type_mapper/3 from the stage's erldns_pipeline:prepare/1.
Functions
-spec add_nsec_type_mapper(erldns_pipeline:opts(), [dns:type()], nsec_type_mapper_fun()) -> erldns_pipeline:opts().
Register an NSEC type mapper for the given record types into the pipeline opts.
Extension pipes call this from their own erldns_pipeline:prepare/1. Because every pipe's
prepare/1 contributes to the single, shared pipeline opts that is later merged into every query,
the mappers are available to this module's call/2 at run-time as a plain map lookup — no global
registry, no process hop.
-spec call(dns:message(), erldns_pipeline:opts()) -> erldns_pipeline:return().
erldns_pipeline:call/2 callback.
-spec deps() -> erldns_pipeline:deps().
erldns_pipeline:deps/0 callback.
-spec get_signed_records(erldns:zone()) -> #{atom() => [dns:rr()]}.
Get signed records from a zone.
Key records (DNSKEY, CDS, CDNSKEY) are signed with the key signing key, everything else with the zone signing key. NS RRsets at delegation points, glue, and any other data occluded by a zone cut are not authoritative in this zone and are left unsigned (RFC 4035 §2.2); the DS RRset at a cut is the parent's own data and is signed like the rest.
-spec get_signed_zone_records(erldns:zone()) -> [dns:rr()].
Get the records of a zone signed with the zone signing key.
Same rules as get_signed_records/1, for one RRset: the zone cuts are looked up in the zone cache,
where the rest of the zone is.
-spec prepare(erldns_pipeline:opts()) -> erldns_pipeline:opts().
erldns_pipeline:prepare/1 callback.
-spec rrsig_for_zone_rrset(erldns:zone(), [dns:rr()]) -> [dns:rr()].
Given a zone and a set of records, return the RRSIG records.