Skip to content

Commit d3bdbff

Browse files
committed
Support DNSSEC single type signing scheme without ZSK
1 parent b365ddd commit d3bdbff

File tree

8 files changed

+44
-4
lines changed

8 files changed

+44
-4
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ group :test do
99
gem "rspec", '> 3.4.0'
1010
gem "rspec-puppet"
1111
gem "rspec-puppet-facts"
12+
gem "rspec-command"
1213
gem 'rubocop', '> 0.47.0', '< 0.49.0'
1314
gem 'simplecov', '>= 0.11.0'
1415
gem 'simplecov-console'

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ bind::zone { 'example.com-external':
182182
}
183183
```
184184

185+
Set parameter `dnssec_ksk_only => true` if a DNSSEC zone should only be signed with a key signing key and no zone signing key should be created.
186+
185187
A master zone which is initialized with a pre-existing zone file (for example, to migrate an existing zone to a
186188
bind-module controlled server or to recover from a backup):
187189

files/dnssec-init

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@ KEY_DIRECTORY="${4:-${CACHEDIR}/${NAME}}"
77
RANDOM_DEVICE="$5"
88
NSEC3_SALT="$6"
99
ZONE_FILE="$7"
10+
DNSSEC_KSK_ONLY="$8"
1011
PATH=/bin:/sbin:/usr/bin:/usr/sbin
1112

12-
dnssec-keygen -a RSASHA256 -b 1024 -r "${RANDOM_DEVICE}" -K "${KEY_DIRECTORY}" "${DOMAIN}"
13+
if [ "$DNSSEC_KSK_ONLY" != "true" ]; then
14+
dnssec-keygen -a RSASHA256 -b 1024 -r "${RANDOM_DEVICE}" -K "${KEY_DIRECTORY}" "${DOMAIN}"
15+
fi
1316
dnssec-keygen -a RSASHA256 -b 2048 -r "${RANDOM_DEVICE}" -f KSK -K "${KEY_DIRECTORY}" "${DOMAIN}"
1417

18+
if [ "$DNSSEC_KSK_ONLY" ]; then
19+
DNSSEC_KSK_ONLY_SIGN_OPTIONS="-z"
20+
fi
1521
if [ "$NSEC3_SALT" != '' ]; then
16-
dnssec-signzone -S -u -3 "${NSEC3_SALT}" -d "${CACHEDIR}" -K "${KEY_DIRECTORY}" -o "${DOMAIN}" "${CACHEDIR}/${NAME}/${ZONE_FILE}"
22+
dnssec-signzone -S ${DNSSEC_KSK_ONLY_SIGN_OPTIONS} -u -3 "${NSEC3_SALT}" -d "${CACHEDIR}" -K "${KEY_DIRECTORY}" -o "${DOMAIN}" "${CACHEDIR}/${NAME}/${ZONE_FILE}"
1723
else
18-
dnssec-signzone -S -d "${CACHEDIR}" -K "${KEY_DIRECTORY}" -o "${DOMAIN}" "${CACHEDIR}/${NAME}/${ZONE_FILE}"
24+
dnssec-signzone -S ${DNSSEC_KSK_ONLY_SIGN_OPTIONS} -d "${CACHEDIR}" -K "${KEY_DIRECTORY}" -o "${DOMAIN}" "${CACHEDIR}/${NAME}/${ZONE_FILE}"
1925
fi

manifests/zone.pp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
$update_policies = '',
1212
$allow_transfers = '',
1313
$dnssec = false,
14+
$dnssec_ksk_only = false,
1415
$nsec3_salt = '',
1516
$key_directory = '',
1617
$ns_notify = true,
@@ -131,7 +132,7 @@
131132
exec { "dnssec-keygen-${name}":
132133
command => "/usr/local/bin/dnssec-init '${cachedir}' '${name}'\
133134
'${_domain}' '${key_directory}' '${random_device}' '${nsec3_salt}'\
134-
'${zone_file}'",
135+
'${zone_file}' '${dnssec_ksk_only}'",
135136
cwd => $cachedir,
136137
user => $bind_user,
137138
creates => "${cachedir}/${name}/${zone_file}.signed",
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
$TTL 86400
2+
@ IN SOA localhost. root.localhost. (
3+
1 ; Serial
4+
60 ; Refresh
5+
30 ; Retry
6+
300 ; Expire
7+
10 ) ; Negative Cache TTL
8+
;
9+
@ IN NS example.com.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# ex: syntax=ruby ts=2 sw=2 si et
2+
require 'spec_helper'
3+
4+
describe 'dnssec-init should create RSASHA256 KSK and ZSK' do
5+
fixture_file '../../files/dnssec-init'
6+
fixture_file 'files/zones'
7+
command '/bin/sh dnssec-init . example.com example.com . /dev/urandom 12345678 example.com.zone'
8+
its(:stdout) { is_expected.to match(/^Kexample\.com\.\+008\+[0-9]+\nKexample\.com\.\+008\+[0-9]+\n\.\/example\.com\/example\.com\.zone\.signed$/m) }
9+
end
10+
11+
describe 'dnssec-init should create RSASHA256 KSK only' do
12+
fixture_file '../../files/dnssec-init'
13+
fixture_file 'files/zones'
14+
command '/bin/sh dnssec-init . example.com example.com . /dev/urandom 12345678 example.com.zone true'
15+
its(:stdout) { is_expected.to match(/^Kexample\.com\.\+008\+[0-9]+\n\.\/example\.com\/example\.com\.zone\.signed$/m) }
16+
end

spec/spec_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
require 'puppetlabs_spec_helper/module_spec_helper'
22
require 'rspec-puppet-facts'
33
require 'rspec-puppet'
4+
require 'rspec_command'
45

56
include RspecPuppetFacts
67

78
RSpec.configure do |c|
9+
c.include RSpecCommand
810
c.hiera_config = File.expand_path(File.join(__FILE__, '../fixtures/hiera.yaml'))
911
c.after(:suite) do
1012
RSpec::Puppet::Coverage.report!

templates/zone.conf.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ zone "<%= @_domain %>" {
44
type <%= @zone_type %>;
55
<%- if @dnssec -%>
66
auto-dnssec maintain;
7+
<%- if @dnssec_ksk_only -%>
8+
update-check-ksk no;
9+
<%- end -%>
710
<%- if @key_directory and @key_directory != '' -%>
811
key-directory "<%= @key_directory %>";
912
<%- else -%>

0 commit comments

Comments
 (0)