Skip to content

Commit

Permalink
RRSIG headers fix
Browse files Browse the repository at this point in the history
  • Loading branch information
semihalev committed Oct 14, 2018
1 parent 30c0c4d commit 45fe609
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ $ go build
* Query based ratelimit
* Black-hole internet advertisements and malware servers
* HTTP API support
* Outbount IP selection
* Outbound IP selection

## TODO

Expand Down
6 changes: 6 additions & 0 deletions resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ func (r *Resolver) Resolve(Net string, req *dns.Msg, servers []string, root bool
var signerFound bool

for _, rr := range resp.Answer {
if rr.Header().Name != req.Question[0].Name {
continue
}
if sigrec, ok := rr.(*dns.RRSIG); ok {
signer = sigrec.SignerName
signerFound = true
Expand Down Expand Up @@ -277,6 +280,9 @@ func (r *Resolver) Resolve(Net string, req *dns.Msg, servers []string, root bool
var signerFound bool

for _, rr := range resp.Ns {
if rr.Header().Name != nsrec.Header().Name {
continue
}
if sigrec, ok := rr.(*dns.RRSIG); ok {
signer = sigrec.SignerName
signerFound = true
Expand Down
6 changes: 6 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,14 @@ func verifyRRSIG(keys map[uint16]*dns.DNSKEY, msg *dns.Msg) error {
return errNoSignatures
}

main:
for _, sigRR := range sigs {
sig := sigRR.(*dns.RRSIG)
for _, k := range keys {
if !strings.HasPrefix(sig.Header().Name, k.Header().Name) {
continue main
}
}
rest := extractRRSet(rr, sig.Header().Name, sig.TypeCovered)
if len(rest) == 0 {
return errMissingSigned
Expand Down

0 comments on commit 45fe609

Please sign in to comment.