From cbe8b1866fdd3c00f67f9c70d38ce32f63f47392 Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Thu, 9 Nov 2017 16:56:30 +0100 Subject: [PATCH] API: Allow disabling DNSSEC Closes #5909 Closes #5910 --- pdns/dbdnsseckeeper.cc | 20 ++++++++++++++++++++ pdns/dnsseckeeper.hh | 1 + pdns/pdnsutil.cc | 22 +++++----------------- pdns/ws-auth.cc | 10 +++++++++- regression-tests.api/test_Zones.py | 24 ++++++++++++++++++++++++ 5 files changed, 59 insertions(+), 18 deletions(-) diff --git a/pdns/dbdnsseckeeper.cc b/pdns/dbdnsseckeeper.cc index c8369b21e..aca1b38d3 100644 --- a/pdns/dbdnsseckeeper.cc +++ b/pdns/dbdnsseckeeper.cc @@ -589,6 +589,26 @@ bool DNSSECKeeper::getTSIGForAccess(const DNSName& zone, const string& master, D return false; } +bool DNSSECKeeper::unSecureZone(const DNSName& zone, string& error, string& info) { + // Not calling isSecuredZone(), as it will return false for zones with zero + // active keys. + DNSSECKeeper::keyset_t keyset=getKeys(zone); + + if(keyset.empty()) { + error = "No keys for zone '" + zone.toLogString() + "'."; + return false; + } + + for(auto& key : keyset) { + deactivateKey(zone, key.second.id); + removeKey(zone, key.second.id); + } + + unsetNSEC3PARAM(zone); + unsetPresigned(zone); + return true; +} + /* Rectifies the zone * * \param zone The zone to rectify diff --git a/pdns/dnsseckeeper.hh b/pdns/dnsseckeeper.hh index 2a3f878dc..044b7f294 100644 --- a/pdns/dnsseckeeper.hh +++ b/pdns/dnsseckeeper.hh @@ -210,6 +210,7 @@ public: void getFromMeta(const DNSName& zname, const std::string& key, std::string& value); void getSoaEdit(const DNSName& zname, std::string& value); + bool unSecureZone(const DNSName& zone, std::string& error, std::string& info); bool rectifyZone(const DNSName& zone, std::string& error, std::string& info, bool doTransaction); private: diff --git a/pdns/pdnsutil.cc b/pdns/pdnsutil.cc index 189d39f6d..b46572eb2 100644 --- a/pdns/pdnsutil.cc +++ b/pdns/pdnsutil.cc @@ -1358,24 +1358,12 @@ bool disableDNSSECOnZone(DNSSECKeeper& dk, const DNSName& zone) return false; } - if(!dk.isSecuredZone(zone)) { - cerr<<"Zone is not secured"<