7. DNSSEC
Cryptographic authentication of DNS information is possible through the DNS Security (“DNSSEC-bis”) extensions, defined in RFC 4033, RFC 4034, and RFC 4035. This section describes the creation and use of DNSSEC signed zones.
In order to set up a DNSSEC secure zone, there are a series of steps
which must be followed. BIND 9 ships with several tools that are used in
this process, which are explained in more detail below. In all cases,
the -h
option prints a full list of parameters. Note that the DNSSEC
tools require the keyset files to be in the working directory or the
directory specified by the -d
option.
There must also be communication with the administrators of the parent
and/or child zone to transmit keys. A zone’s security status must be
indicated by the parent zone for a DNSSEC-capable resolver to trust its
data. This is done through the presence or absence of a DS
record at
the delegation point.
For other servers to trust data in this zone, they must be statically configured with either this zone’s zone key or the zone key of another zone above this one in the DNS tree.
7.1. DNSSEC Keys
7.1.1. Generating Keys
The dnssec-keygen
program is used to generate keys.
A secure zone must contain one or more zone keys. The zone keys
sign all other records in the zone, as well as the zone keys of any
secure delegated zones. Zone keys must have the same name as the zone, have a
name type of ZONE
, and be usable for authentication. It is
recommended that zone keys use a cryptographic algorithm designated as
“mandatory to implement” by the IETF. Currently there are two algorithms,
RSASHA256 and ECDSAP256SHA256; ECDSAP256SHA256 is recommended for
current and future deployments.
The following command generates an ECDSAP256SHA256 key for the
child.example
zone:
dnssec-keygen -a ECDSAP256SHA256 -n ZONE child.example.
Two output files are produced: Kchild.example.+013+12345.key
and
Kchild.example.+013+12345.private
(where 12345 is an example of a
key tag). The key filenames contain the key name (child.example.
),
the algorithm (5 is RSASHA1, 8 is RSASHA256, 13 is ECDSAP256SHA256, 15 is
ED25519, etc.), and the key tag (12345 in this case). The private key (in
the .private
file) is used to generate signatures, and the public
key (in the .key
file) is used for signature verification.
To generate another key with the same properties but with a different key tag, repeat the above command.
The dnssec-keyfromlabel
program is used to get a key pair from a
crypto hardware device and build the key files. Its usage is similar to
dnssec-keygen
.
The public keys should be inserted into the zone file by including the
.key
files using $INCLUDE
statements.
7.1.2. Signing the Zone
The dnssec-signzone
program is used to sign a zone.
Any keyset
files corresponding to secure sub-zones should be
present. The zone signer generates NSEC
, NSEC3
, and RRSIG
records for the zone, as well as DS
for the child zones if -g
is specified. If -g
is not specified, then DS RRsets for the
secure child zones need to be added manually.
By default, all zone keys which have an available private key are used
to generate signatures. The following command signs the zone, assuming
it is in a file called zone.child.example
:
dnssec-signzone -o child.example zone.child.example
One output file is produced: zone.child.example.signed
. This file
should be referenced by named.conf
as the input file for the zone.
dnssec-signzone
also produces keyset and dsset files. These are used
to provide the parent zone administrators with the DNSKEYs
(or their
corresponding DS
records) that are the secure entry point to the zone.
7.1.3. Configuring Servers for DNSSEC
To enable named
to validate answers received from other servers, the
dnssec-validation
option must be set to either yes
or auto
.
When dnssec-validation
is set to auto
, a trust anchor for the
DNS root zone is automatically used. This trust anchor is provided
as part of BIND and is kept up to date using RFC 5011 key management.
When dnssec-validation
is set to yes
, DNSSEC validation
only occurs if at least one trust anchor has been explicitly configured
in named.conf
, using a trust-anchors
statement (or the
managed-keys
and trusted-keys
statements, both deprecated).
When dnssec-validation
is set to no
, DNSSEC validation does not
occur.
The default is auto
unless BIND is built with
configure --disable-auto-validation
, in which case the default is
yes
.
The keys specified in trust-anchors
are copies of DNSKEY RRs for zones that are
used to form the first link in the cryptographic chain of trust. Keys configured
with the keyword static-key
or static-ds
are loaded directly into the
table of trust anchors, and can only be changed by altering the
configuration. Keys configured with initial-key
or initial-ds
are used
to initialize RFC 5011 trust anchor maintenance, and are kept up-to-date
automatically after the first time named
runs.
trust-anchors
is described in more detail later in this document.
BIND 9 does not verify signatures on load, so zone keys for authoritative zones do not need to be specified in the configuration file.
After DNSSEC is established, a typical DNSSEC configuration looks
something like the following. It has one or more public keys for the
root, which allows answers from outside the organization to be validated.
It also has several keys for parts of the namespace that the
organization controls. These are here to ensure that named
is immune
to compromised security in the DNSSEC components of parent zones.
trust-anchors {
/* Root Key */
"." initial-key 257 3 3 "BNY4wrWM1nCfJ+CXd0rVXyYmobt7sEEfK3clRbGaTwS
JxrGkxJWoZu6I7PzJu/E9gx4UC1zGAHlXKdE4zYIpRh
aBKnvcC2U9mZhkdUpd1Vso/HAdjNe8LmMlnzY3zy2Xy
4klWOADTPzSv9eamj8V18PHGjBLaVtYvk/ln5ZApjYg
hf+6fElrmLkdaz MQ2OCnACR817DF4BBa7UR/beDHyp
5iWTXWSi6XmoJLbG9Scqc7l70KDqlvXR3M/lUUVRbke
g1IPJSidmK3ZyCllh4XSKbje/45SKucHgnwU5jefMtq
66gKodQj+MiA21AfUVe7u99WzTLzY3qlxDhxYQQ20FQ
97S+LKUTpQcq27R7AT3/V5hRQxScINqwcz4jYqZD2fQ
dgxbcDTClU0CRBdiieyLMNzXG3";
/* Key for our organization's forward zone */
example.com. static-ds 54135 5 2 "8EF922C97F1D07B23134440F19682E7519ADDAE180E20B1B1EC52E7F58B2831D"
/* Key for our reverse zone. */
2.0.192.IN-ADDRPA.NET. static-key 257 3 5 "AQOnS4xn/IgOUpBPJ3bogzwc
xOdNax071L18QqZnQQQAVVr+i
LhGTnNGp3HoWQLUIzKrJVZ3zg
gy3WwNT6kZo6c0tszYqbtvchm
gQC8CzKojM/W16i6MG/eafGU3
siaOdS0yOI6BgPsw+YZdzlYMa
IJGf4M4dyoKIhzdZyQ2bYQrjy
Q4LB0lC7aOnsMyYKHHYeRvPxj
IQXmdqgOJGq+vsevG06zW+1xg
YJh9rCIfnm1GX/KMgxLPG2vXT
D/RnLX+D3T3UL7HJYHJhAZD5L
59VvjSPsZJHeDCUyWYrvPZesZ
DIRvhDD52SKvbheeTJUm6Ehkz
ytNN2SN96QRk8j/iI8ib";
};
options {
...
dnssec-validation yes;
};
Note
None of the keys listed in this example are valid. In particular, the root key is not valid.
When DNSSEC validation is enabled and properly configured, the resolver rejects any answers from signed, secure zones which fail to validate, and returns SERVFAIL to the client.
Responses may fail to validate for any of several reasons, including missing, expired, or invalid signatures, a key which does not match the DS RRset in the parent zone, or an insecure response from a zone which, according to its parent, should have been secure.
Note
When the validator receives a response from an unsigned zone that has a signed parent, it must confirm with the parent that the zone was intentionally left unsigned. It does this by verifying, via signed and validated NSEC/NSEC3 records, that the parent zone contains no DS records for the child.
If the validator can prove that the zone is insecure, then the response is accepted. However, if it cannot, the validator must assume an insecure response to be a forgery; it rejects the response and logs an error.
The logged error reads “insecurity proof failed” and “got insecure response; parent indicates it should be secure.”
7.2. DNSSEC, Dynamic Zones, and Automatic Signing
7.2.1. Converting From Insecure to Secure
A zone can be changed from insecure to secure in three ways: using a
dynamic DNS update, via the auto-dnssec
zone option, or by setting a
DNSSEC policy for the zone with dnssec-policy
.
For any method, named
must be configured so that it can see
the K*
files which contain the public and private parts of the keys
that are used to sign the zone. These files are generated
by dnssec-keygen
, or created when needed by named
if
dnssec-policy
is used. Keys should be placed in the
key-directory, as specified in named.conf
:
zone example.net {
type primary;
update-policy local;
file "dynamic/example.net/example.net";
key-directory "dynamic/example.net";
};
If one KSK and one ZSK DNSKEY key have been generated, this configuration causes all records in the zone to be signed with the ZSK, and the DNSKEY RRset to be signed with the KSK. An NSEC chain is generated as part of the initial signing process.
With dnssec-policy
, it is possible to specify which keys should be
KSK and/or ZSK. To sign all records with a key, a CSK must be specified.
For example:
dnssec-policy csk {
keys {
csk lifetime unlimited algorithm 13;
};
};
7.2.2. Dynamic DNS Update Method
To insert the keys via dynamic update:
% nsupdate
> ttl 3600
> update add example.net DNSKEY 256 3 7 AwEAAZn17pUF0KpbPA2c7Gz76Vb18v0teKT3EyAGfBfL8eQ8al35zz3Y I1m/SAQBxIqMfLtIwqWPdgthsu36azGQAX8=
> update add example.net DNSKEY 257 3 7 AwEAAd/7odU/64o2LGsifbLtQmtO8dFDtTAZXSX2+X3e/UNlq9IHq3Y0 XtC0Iuawl/qkaKVxXe2lo8Ct+dM6UehyCqk=
> send
While the update request completes almost immediately, the zone is
not completely signed until named
has had time to “walk” the zone
and generate the NSEC and RRSIG records. The NSEC record at the apex
is added last, to signal that there is a complete NSEC chain.
To sign using NSEC3 instead of NSEC, add an NSEC3PARAM record to the initial update request. The OPTOUT bit in the NSEC3 chain can be set in the flags field of the NSEC3PARAM record.
% nsupdate
> ttl 3600
> update add example.net DNSKEY 256 3 7 AwEAAZn17pUF0KpbPA2c7Gz76Vb18v0teKT3EyAGfBfL8eQ8al35zz3Y I1m/SAQBxIqMfLtIwqWPdgthsu36azGQAX8=
> update add example.net DNSKEY 257 3 7 AwEAAd/7odU/64o2LGsifbLtQmtO8dFDtTAZXSX2+X3e/UNlq9IHq3Y0 XtC0Iuawl/qkaKVxXe2lo8Ct+dM6UehyCqk=
> update add example.net NSEC3PARAM 1 1 100 1234567890
> send
Again, this update request completes almost immediately; however,
the record does not show up until named
has had a chance to
build/remove the relevant chain. A private type record is created
to record the state of the operation (see below for more details), and
is removed once the operation completes.
While the initial signing and NSEC/NSEC3 chain generation is happening, other updates are possible as well.
7.2.3. Fully Automatic Zone Signing
To enable automatic signing, set a dnssec-policy
or add the
auto-dnssec
option to the zone statement in named.conf
.
auto-dnssec
has two possible arguments: allow
or maintain
.
With auto-dnssec allow
, named
can search the key directory for
keys matching the zone, insert them into the zone, and use them to sign
the zone. It does so only when it receives an
rndc sign zonename
.
auto-dnssec maintain
includes the above functionality, but also
automatically adjusts the zone’s DNSKEY records on a schedule according to
the keys’ timing metadata. (See dnssec-keygen: DNSSEC key generation tool and
dnssec-settime: set the key timing metadata for a DNSSEC key for more information.)
dnssec-policy
is similar to auto-dnssec maintain
, but
dnssec-policy
also automatically creates new keys when necessary. In
addition, any configuration related to DNSSEC signing is retrieved from the
policy, ignoring existing DNSSEC named.conf
options.
named
periodically searches the key directory for keys matching
the zone; if the keys’ metadata indicates that any change should be
made to the zone - such as adding, removing, or revoking a key - then that
action is carried out. By default, the key directory is checked for
changes every 60 minutes; this period can be adjusted with
dnssec-loadkeys-interval
, up to a maximum of 24 hours. The
rndc loadkeys
command forces named
to check for key updates immediately.
If keys are present in the key directory the first time the zone is
loaded, the zone is signed immediately, without waiting for an
rndc sign
or rndc loadkeys
command. Those commands can still be
used when there are unscheduled key changes.
When new keys are added to a zone, the TTL is set to match that of any
existing DNSKEY RRset. If there is no existing DNSKEY RRset, the
TTL is set to the TTL specified when the key was created (using the
dnssec-keygen -L
option), if any, or to the SOA TTL.
To sign the zone using NSEC3 instead of NSEC, submit an NSEC3PARAM record via dynamic update prior to the scheduled publication and activation of the keys. The OPTOUT bit for the NSEC3 chain can be set in the flags field of the NSEC3PARAM record. The NSEC3PARAM record does not appear in the zone immediately, but it is stored for later reference. When the zone is signed and the NSEC3 chain is completed, the NSEC3PARAM record appears in the zone.
Using the auto-dnssec
option requires the zone to be configured to
allow dynamic updates, by adding an allow-update
or
update-policy
statement to the zone configuration. If this has not
been done, the configuration fails.
7.2.4. Private Type Records
The state of the signing process is signaled by private type records (with a default type value of 65534). When signing is complete, those records with a non-zero initial octet have a non-zero value for the final octet.
If the first octet of a private type record is non-zero, the record indicates either that the zone needs to be signed with the key matching the record, or that all signatures that match the record should be removed. Here are the meanings of the different values of the first octet:
algorithm (octet 1)
key id in network order (octet 2 and 3)
removal flag (octet 4)
complete flag (octet 5)
Only records flagged as “complete” can be removed via dynamic update; attempts to remove other private type records are silently ignored.
If the first octet is zero (this is a reserved algorithm number that should never appear in a DNSKEY record), the record indicates that changes to the NSEC3 chains are in progress. The rest of the record contains an NSEC3PARAM record, while the flag field tells what operation to perform based on the flag bits:
0x01 OPTOUT
0x80 CREATE
0x40 REMOVE
0x20 NONSEC
7.2.5. DNSKEY Rollovers
As with insecure-to-secure conversions, DNSSEC keyrolls can be done
in two ways: using a dynamic DNS update, or via the auto-dnssec
zone
option.
7.2.6. Dynamic DNS Update Method
To perform key rollovers via a dynamic update, the K*
files for the new keys must be added so that named
can find them.
The new DNSKEY RRs can then be added via dynamic update. named
then causes the
zone to be signed with the new keys; when the signing is complete, the
private type records are updated so that the last octet is non-zero.
If this is for a KSK, the parent and any trust anchor repositories of the new KSK must be informed.
The maximum TTL in the zone must expire before removing the old DNSKEY. If it is a KSK that is being updated, the DS RRset in the parent must also be updated and its TTL allowed to expire. This ensures that all clients are able to verify at least one signature when the old DNSKEY is removed.
The old DNSKEY can be removed via UPDATE, taking care to specify the
correct key. named
cleans out any signatures generated by the
old key after the update completes.
7.2.7. Automatic Key Rollovers
When a new key reaches its activation date (as set by dnssec-keygen
or dnssec-settime
), and if the auto-dnssec
zone option is set to
maintain
, named
automatically carries out the key rollover.
If the key’s algorithm has not previously been used to sign the zone,
then the zone is fully signed as quickly as possible. However, if
the new key replaces an existing key of the same algorithm, the
zone is re-signed incrementally, with signatures from the old key
replaced with signatures from the new key as their signature
validity periods expire. By default, this rollover completes in 30 days,
after which it is safe to remove the old key from the DNSKEY RRset.
7.2.8. NSEC3PARAM Rollovers via UPDATE
The new NSEC3PARAM record can be added via dynamic update. When the new NSEC3 chain has been generated, the NSEC3PARAM flag field is set to zero. At that point, the old NSEC3PARAM record can be removed. The old chain is removed after the update request completes.
7.2.9. Converting From NSEC to NSEC3
Add a nsec3param
option to your dnssec-policy
and
run rndc reconfig
.
Or use nsupdate
to add an NSEC3PARAM record.
In both cases, the NSEC3 chain is generated and the NSEC3PARAM record is added before the NSEC chain is destroyed.
7.2.10. Converting From NSEC3 to NSEC
To do this, remove the nsec3param
option from the dnssec-policy
and
run rndc reconfig
.
Or use nsupdate
to remove all NSEC3PARAM records with a
zero flag field. The NSEC chain is generated before the NSEC3 chain
is removed.
7.2.11. Converting From Secure to Insecure
To convert a signed zone to unsigned using dynamic DNS, delete all the
DNSKEY records from the zone apex using nsupdate
. All signatures,
NSEC or NSEC3 chains, and associated NSEC3PARAM records are removed
automatically. This takes place after the update request completes.
This requires the dnssec-secure-to-insecure
option to be set to
yes
in named.conf
.
In addition, if the auto-dnssec maintain
zone statement is used, it
should be removed or changed to allow
instead; otherwise it will re-sign.
7.2.12. Periodic Re-signing
In any secure zone which supports dynamic updates, named
periodically re-signs RRsets which have not been re-signed as a result of
some update action. The signature lifetimes are adjusted to
spread the re-sign load over time rather than all at once.
7.2.13. NSEC3 and OPTOUT
named
only supports creating new NSEC3 chains where all the NSEC3
records in the zone have the same OPTOUT state. named
supports
UPDATES to zones where the NSEC3 records in the chain have mixed OPTOUT
state. named
does not support changing the OPTOUT state of an
individual NSEC3 record; if the
OPTOUT state of an individual NSEC3 needs to be changed, the entire chain must be changed.
7.3. Dynamic Trust Anchor Management
BIND is able to maintain DNSSEC trust anchors using RFC 5011 key
management. This feature allows named
to keep track of changes to
critical DNSSEC keys without any need for the operator to make changes
to configuration files.
7.3.1. Validating Resolver
To configure a validating resolver to use RFC 5011 to maintain a trust
anchor, configure the trust anchor using a trust-anchors
statement and
the initial-key
keyword. Information about this can be found in
trust-anchors Statement Definition and Usage.
7.4. PKCS#11 (Cryptoki) Support
Public Key Cryptography Standard #11 (PKCS#11) defines a platform-independent API for the control of hardware security modules (HSMs) and other cryptographic support devices.
PKCS#11 uses a “provider library”: a dynamically loadable library which provides a low-level PKCS#11 interface to drive the HSM hardware. The PKCS#11 provider library comes from the HSM vendor, and it is specific to the HSM to be controlled.
BIND 9 uses engine_pkcs11 for PKCS#11. engine_pkcs11 is an OpenSSL engine which is part of the OpenSC project. The engine is dynamically loaded into OpenSSL and the HSM is operated indirectly; any cryptographic operations not supported by the HSM can be carried out by OpenSSL instead.
7.4.1. Prerequisites
See the documentation provided by the HSM vendor for information about installing, initializing, testing, and troubleshooting the HSM.
7.4.2. Building SoftHSMv2
SoftHSMv2, the latest development version of SoftHSM, is available from https://github.com/opendnssec/SoftHSMv2. It is a software library developed by the OpenDNSSEC project (https://www.opendnssec.org) which provides a PKCS#11 interface to a virtual HSM, implemented in the form of an SQLite3 database on the local filesystem. It provides less security than a true HSM, but it allows users to experiment with native PKCS#11 when an HSM is not available. SoftHSMv2 can be configured to use either OpenSSL or the Botan library to perform cryptographic functions, but when using it for native PKCS#11 in BIND, OpenSSL is required.
By default, the SoftHSMv2 configuration file is prefix/etc/softhsm2.conf
(where prefix
is configured at compile time). This location can be
overridden by the SOFTHSM2_CONF environment variable. The SoftHSMv2
cryptographic store must be installed and initialized before using it
with BIND.
$ cd SoftHSMv2
$ configure --with-crypto-backend=openssl --prefix=/opt/pkcs11/usr
$ make
$ make install
$ /opt/pkcs11/usr/bin/softhsm-util --init-token 0 --slot 0 --label softhsmv2
7.4.3. OpenSSL-based PKCS#11
OpenSSL-based PKCS#11 uses engine_pkcs11 OpenSSL engine from libp11 project.
engine_pkcs11 tries to fit the PKCS#11 API within the engine API of OpenSSL. That is, it provides a gateway between PKCS#11 modules and the OpenSSL engine API. One has to register the engine with OpenSSL and one has to provide the path to the PKCS#11 module which should be gatewayed to. This can be done by editing the OpenSSL configuration file, by engine specific controls, or by using the p11-kit proxy module.
It is recommended, that libp11 >= 0.4.12 is used.
For more detailed howto including the examples, we recommend reading:
https://gitlab.isc.org/isc-projects/bind9/-/wikis/BIND-9-PKCS11
7.4.4. Using the HSM
The canonical documentation for configuring engine_pkcs11 is in the libp11/README.md, but here’s copy of working configuration for your convenience:
We are going to use our own custom copy of OpenSSL configuration, again it’s
driven by an environment variable, this time called OPENSSL_CONF. We are
going to copy the global OpenSSL configuration (often found in
etc/ssl/openssl.conf
) and customize it to use engines_pkcs11.
cp /etc/ssl/openssl.cnf /opt/bind9/etc/openssl.cnf
and export the environment variable:
export OPENSSL_CONF=/opt/bind9/etc/openssl.cnf
Now add following line at the top of file, before any sections (in square brackets) are defined:
openssl_conf = openssl_init
And make sure there are no other ‘openssl_conf = …’ lines in the file.
Add following lines at the bottom of the file:
[openssl_init]
engines=engine_section
[engine_section]
pkcs11 = pkcs11_section
[pkcs11_section]
engine_id = pkcs11
dynamic_path = <PATHTO>/pkcs11.so
MODULE_PATH = <FULL_PATH_TO_HSM_MODULE>
init = 0
7.4.5. Key Generation
HSM keys can now be created and used. We are going to assume that you already
have a BIND 9 installed, either from a package, or from the sources, and the
tools are readily available in the $PATH
.
For generating the keys, we are going to use pkcs11-tool
available from the
OpenSC suite. On both DEB-based and RPM-based distributions, the package is
called opensc.
We need to generate at least two RSA keys:
pkcs11-tool --module <FULL_PATH_TO_HSM_MODULE> -l -k --key-type rsa:2048 --label example.net-ksk --pin <PIN>
pkcs11-tool --module <FULL_PATH_TO_HSM_MODULE> -l -k --key-type rsa:2048 --label example.net-zsk --pin <PIN>
Remember that each key should have unique label and we are going to use that label to reference the private key.
Convert the RSA keys stored in the HSM into a format that BIND 9 understands.
The dnssec-keyfromlabel
tool from BIND 9 can link the raw keys stored in the
HSM with the K<zone>+<alg>+<id>
files. You’ll need to provide the OpenSSL
engine name (pkcs11
), the algorithm (RSASHA256
) and the PKCS#11 label
that specify the token (we asume that it has been initialized as bind9), the
name of the PKCS#11 object (called label when generating the keys using
pkcs11-tool
) and the HSM PIN.
Convert the KSK:
dnssec-keyfromlabel -E pkcs11 -a RSASHA256 -l "token=bind9;object=example.net-ksk;pin-value=0000" -f KSK example.net
and ZSK:
dnssec-keyfromlabel -E pkcs11 -a RSASHA256 -l "token=bind9;object=example.net-zsk;pin-value=0000" example.net
NOTE: you can use PIN stored on disk, by specifying pin-source=<path_to>/<file>
, f.e.:
(umask 0700 && echo -n 0000 > /opt/bind9/etc/pin.txt)
and then use in the label specification:
pin-source=/opt/bind9/etc/pin.txt
Confirm that you have one KSK and one ZSK present in the current directory:
ls -l K*
The output should look like this (the second number will be different):
Kexample.net.+008+31729.key
Kexample.net.+008+31729.private
Kexample.net.+008+42231.key
Kexample.net.+008+42231.private
A note on generating ECDSA keys: there is a bug in libp11 when looking up a key, that function compares keys only on their ID, not the label. So when looking up a key it returns the first key, rather than the matching key. The workaround for this is when creating ECDSA keys, you should specify a unique ID:
ksk=$(echo "example.net-ksk" | sha1sum - | awk '{print $1}')
zsk=$(echo "example.net-zsk" | sha1sum - | awk '{print $1}')
pkcs11-tool --module <FULL_PATH_TO_HSM_MODULE> -l -k --key-type EC:prime256v1 --id $ksk --label example.net-ksk --pin <PIN>
pkcs11-tool --module <FULL_PATH_TO_HSM_MODULE> -l -k --key-type EC:prime256v1 --id $zsk --label example.net-zsk --pin <PIN>
7.4.6. Specifying the Engine on the Command Line
When using OpenSSL-based PKCS#11, the “engine” to be used by OpenSSL can be
specified in named
and all of the BIND dnssec-*
tools by using the -E
<engine>
command line option. Specifying the engine is generally not necessary
unless a different OpenSSL engine is used.
The zone signing commences as usual, with only one small difference. We need to provide the name of the OpenSSL engine using the -E command line option.
dnssec-signzone -E pkcs11 -S -o example.net example.net
7.4.7. Running named
With Automatic Zone Re-signing
The zone can also be signed automatically by named. Again, we need to provide
the name of the OpenSSL engine using the -E
command line option.
named -E pkcs11 -c named.conf
and the logs should have lines like:
Fetching example.net/RSASHA256/31729 (KSK) from key repository.
DNSKEY example.net/RSASHA256/31729 (KSK) is now published
DNSKEY example.net/RSA256SHA256/31729 (KSK) is now active
Fetching example.net/RSASHA256/42231 (ZSK) from key repository.
DNSKEY example.net/RSASHA256/42231 (ZSK) is now published
DNSKEY example.net/RSA256SHA256/42231 (ZSK) is now active
For named
to dynamically re-sign zones using HSM keys,
and/or to sign new records inserted via nsupdate, named
must
have access to the HSM PIN. In OpenSSL-based PKCS#11, this is
accomplished by placing the PIN into the openssl.cnf
file (in the above
examples, /opt/pkcs11/usr/ssl/openssl.cnf
).
The location of the openssl.cnf file can be overridden by setting the
OPENSSL_CONF
environment variable before running named
.
Here is a sample openssl.cnf
:
openssl_conf = openssl_def
[ openssl_def ]
engines = engine_section
[ engine_section ]
pkcs11 = pkcs11_section
[ pkcs11_section ]
PIN = <PLACE PIN HERE>
This also allows the dnssec-\*
tools to access the HSM without PIN
entry. (The pkcs11-\*
tools access the HSM directly, not via OpenSSL, so
a PIN is still required to use them.)