diff --git a/dnssec.go b/dnssec.go index 88f49521..b0fd5cd4 100644 --- a/dnssec.go +++ b/dnssec.go @@ -428,12 +428,12 @@ func (rr *RRSIG) Verify(k *DNSKEY, rrset []RR) error { // ValidityPeriod uses RFC1982 serial arithmetic to calculate // if a signature period is valid. If t is the zero time, the // current time is taken other t is. -func (rr *RRSIG) ValidityPeriod(t time.Tim) bool { +func (rr *RRSIG) ValidityPeriod(t time.Time) bool { var utc int64 - if t == time.Zero { + if t.IsZero() { utc = time.Now().UTC().Unix() } else { - utc = t.Now().UTC().Unix() + utc = t.UTC().Unix() } modi := (int64(rr.Inception) - utc) / year68 mode := (int64(rr.Expiration) - utc) / year68 diff --git a/dnssec_test.go b/dnssec_test.go index fd905de7..e1c3858d 100644 --- a/dnssec_test.go +++ b/dnssec_test.go @@ -8,6 +8,7 @@ import ( "crypto/rsa" "strings" "testing" + "time" ) func getKey() *DNSKEY { @@ -124,14 +125,14 @@ func TestSignature(t *testing.T) { sig.Signature = "AwEAAaHIwpx3w4VHKi6i1LHnTaWeHCL154Jug0Rtc9ji5qwPXpBo6A5sRv7cSsPQKPIwxLpyCrbJ4mr2L0EPOdvP6z6YfljK2ZmTbogU9aSU2fiq/4wjxbdkLyoDVgtO+JsxNN4bjr4WcWhsmk1Hg93FV9ZpkWb0Tbad8DFqNDzr//kZ" // Should not be valid - if sig.ValidityPeriod() { + if sig.ValidityPeriod(time.Now()) { t.Log("Should not be valid") t.Fail() } sig.Inception = 315565800 //Tue Jan 1 10:10:00 CET 1980 sig.Expiration = 4102477800 //Fri Jan 1 10:10:00 CET 2100 - if !sig.ValidityPeriod() { + if !sig.ValidityPeriod(time.Now()) { t.Log("Should be valid") t.Fail() }