If an absolute domain name (i.e. ends in a '.' like "example.com.") is used with ssl/tls, the certificate will be reported as invalid. In matchHostnames, the host and patterns are split on '.' and if the lengths of the resulting slices do not match, the function returns false. When splitting an absolute domain name on '.', the slice will have an extra empty string at the end. This empty string should be discarded before comparison, if present.
$ go env
GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/scott/src/gocode"
GORACE=""
GOROOT="/Users/scott/go1.4.1/go"
GOTOOLDIR="/Users/scott/go1.4.1/go/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"
Example code:
package main
import (
"log"
"net/http"
)
func main() {
_, err := http.Get("https://api.github.com./users/rubyist")
if err != nil {
log.Fatal(err)
}
}
Output:
2015/02/10 10:35:20 Get https://api.github.com./users/rubyist: x509: certificate is valid for *.github.com, github.com, not api.github.com.
exit status 1
If an absolute domain name (i.e. ends in a '.' like "example.com.") is used with ssl/tls, the certificate will be reported as invalid. In
matchHostnames, the host and patterns are split on '.' and if the lengths of the resulting slices do not match, the function returns false. When splitting an absolute domain name on '.', the slice will have an extra empty string at the end. This empty string should be discarded before comparison, if present.Example code:
Output: