X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=tls%2Fdane.go;h=b970cc226fc9276563b15b2e613a2e651710a83a;hb=df6f0b184c5689eab0a4b4be4769902200f2b241;hp=ba6e7d059422718af4c74e934df409940c9afc43;hpb=12ef431d87442cac2111a0d3af3d13017e695348;p=tofuproxy.git diff --git a/tls/dane.go b/tls/dane.go index ba6e7d0..b970cc2 100644 --- a/tls/dane.go +++ b/tls/dane.go @@ -25,7 +25,6 @@ import ( "encoding/hex" "fmt" "log" - "strings" "github.com/miekg/dns" ) @@ -36,12 +35,13 @@ func DANE(addr string, cert *x509.Certificate) (bool, bool) { if DNSSrv == "" { return false, false } - host := addr - port := "443" - cols := strings.Split(addr, ":") - if len(cols) > 1 { - host = cols[0] - port = cols[1] + host, port, err := SplitHostPort(addr) + if err != nil { + log.Printf("can not split host+port: %s: %+v\n", addr, err) + return false, false + } + if port == "" { + port = "443" } m := new(dns.Msg) m.SetQuestion(dns.Fqdn(fmt.Sprintf("_%s._tcp.%s", port, host)), dns.TypeTLSA)