Skip to content

Commit

Permalink
Merge pull request #7081 from mind04/offset
Browse files Browse the repository at this point in the history
rec: extend the validity period of signatures by a number of seconds
  • Loading branch information
Habbie committed Nov 6, 2018
2 parents 1ab9a5c + ffa248e commit 6bd6f07
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
7 changes: 7 additions & 0 deletions pdns/pdns_recursor.cc
Expand Up @@ -3465,6 +3465,12 @@ static int serviceMain(int argc, char*argv[])
exit(1);
}

g_signatureInceptionSkew = ::arg().asNum("signature-inception-skew");
if (g_signatureInceptionSkew < 0) {
g_log<<Logger::Error<<"A negative value for 'signature-inception-skew' is not allowed"<<endl;
exit(1);
}

g_dnssecLogBogus = ::arg().mustDo("dnssec-log-bogus");
g_maxNSEC3Iterations = ::arg().asNum("nsec3-max-iterations");

Expand Down Expand Up @@ -4061,6 +4067,7 @@ int main(int argc, char **argv)
::arg().set("trace","if we should output heaps of logging. set to 'fail' to only log failing domains")="off";
::arg().set("dnssec", "DNSSEC mode: off/process-no-validate (default)/process/log-fail/validate")="process-no-validate";
::arg().set("dnssec-log-bogus", "Log DNSSEC bogus validations")="no";
::arg().set("signature-inception-skew", "Allow the signture inception to be off by this number of seconds")="60";
::arg().set("daemon","Operate as a daemon")="no";
::arg().setSwitch("write-pid","Write a PID file")="yes";
::arg().set("loglevel","Amount of logging. Higher is more. Do not set below 3")="6";
Expand Down
15 changes: 15 additions & 0 deletions pdns/recursordist/docs/settings.rst
Expand Up @@ -1196,6 +1196,21 @@ Query example (where 192.0.2.14 is your server):
PowerDNS can change its user and group id after binding to its socket.
Can be used for better :doc:`security <security>`.

.. _setting-signature-inception-skew:

``signature-inception-skew``
----------------------------------
.. versionadded:: 4.1.5

- Integer
- Default: 60

Allow the signature inception to be off by this number of seconds. Negative values are not allowed.

.. versionchanged:: 4.2.0

Default is now 60, was 0 before.

.. _setting-single-socket:

``single-socket``
Expand Down
5 changes: 3 additions & 2 deletions pdns/validate.cc
Expand Up @@ -6,6 +6,7 @@
#include "base32.hh"
#include "logger.hh"
bool g_dnssecLOG{false};
time_t g_signatureInceptionSkew{0};
uint16_t g_maxNSEC3Iterations{0};

#define LOG(x) if(g_dnssecLOG) { g_log <<Logger::Warning << x; }
Expand Down Expand Up @@ -676,7 +677,7 @@ static const vector<DNSName> getZoneCuts(const DNSName& begin, const DNSName& en

bool isRRSIGNotExpired(const time_t now, const shared_ptr<RRSIGRecordContent> sig)
{
return sig->d_siginception <= now && sig->d_sigexpire >= now;
return sig->d_siginception - g_signatureInceptionSkew <= now && sig->d_sigexpire >= now;
}

static bool checkSignatureWithKey(time_t now, const shared_ptr<RRSIGRecordContent> sig, const shared_ptr<DNSKEYRecordContent> key, const std::string& msg)
Expand All @@ -693,7 +694,7 @@ static bool checkSignatureWithKey(time_t now, const shared_ptr<RRSIGRecordConten
LOG("signature by key with tag "<<sig->d_tag<<" and algorithm "<<DNSSECKeeper::algorithm2name(sig->d_algorithm)<<" was " << (result ? "" : "NOT ")<<"valid"<<endl);
}
else {
LOG("Signature is "<<((sig->d_siginception > now) ? "not yet valid" : "expired")<<" (inception: "<<sig->d_siginception<<", expiration: "<<sig->d_sigexpire<<", now: "<<now<<")"<<endl);
LOG("Signature is "<<((sig->d_siginception - g_signatureInceptionSkew > now) ? "not yet valid" : "expired")<<" (inception: "<<sig->d_siginception<<", inception skew: "<<g_signatureInceptionSkew<<", expiration: "<<sig->d_sigexpire<<", now: "<<now<<")"<<endl);
}
}
catch(const std::exception& e) {
Expand Down
1 change: 1 addition & 0 deletions pdns/validate.hh
Expand Up @@ -28,6 +28,7 @@
#include "dnsrecords.hh"

extern bool g_dnssecLOG;
extern time_t g_signatureInceptionSkew;
extern uint16_t g_maxNSEC3Iterations;

// 4033 5
Expand Down

0 comments on commit 6bd6f07

Please sign in to comment.