mirror of
https://github.com/coredns/coredns.git
synced 2026-04-10 14:05:32 -04:00
core: Add full TSIG verification in DoH transport (#8013)
* core: Add full TSIG verification in DoH transport This PR add full TSIG verification in DoH using dns.TsigVerify() 7943 --------- Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
@@ -19,6 +19,7 @@ import (
|
||||
"github.com/coredns/coredns/plugin/pkg/reuseport"
|
||||
"github.com/coredns/coredns/plugin/pkg/transport"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
"github.com/pires/go-proxyproto"
|
||||
"golang.org/x/net/netutil"
|
||||
)
|
||||
@@ -192,7 +193,7 @@ func (s *ServerHTTPS) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
msg, err := doh.RequestToMsg(r)
|
||||
msg, raw, err := doh.RequestToMsgWire(r)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
s.countResponse(http.StatusBadRequest)
|
||||
@@ -208,6 +209,16 @@ func (s *ServerHTTPS) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
request: r,
|
||||
}
|
||||
|
||||
if tsig := msg.IsTsig(); tsig != nil {
|
||||
if s.tsigSecret == nil {
|
||||
dw.tsigStatus = dns.ErrSecret
|
||||
} else if secret, ok := s.tsigSecret[tsig.Hdr.Name]; !ok {
|
||||
dw.tsigStatus = dns.ErrSecret
|
||||
} else {
|
||||
dw.tsigStatus = dns.TsigVerify(raw, secret, "", false)
|
||||
}
|
||||
}
|
||||
|
||||
// We just call the normal chain handler - all error handling is done there.
|
||||
// We should expect a packet to be returned that we can send to the client.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user