cat main.go
package main
import (
"log"
"net/http"
)
func main() {
if _, err := http.Get("https://www.1823.gov.hk/common/ical/sc.json"); err != nil {
log.Fatalf("Error downloading HK calendar: %v", err)
}
}
go run main.go
Error downloading HK calendar: Get "https://www.1823.gov.hk/common/ical/sc.json": x509: certificate signed by unknown authority
The simple http get to download a JSON through https protocol failed.
If tracing it down into the x509 package, will find that it does not find the right CA in SystemCertPool. But the CA is valid in Safari and it is valid in MacOS KeyChain's SystemRoots (in attached screen shot)

What version of Go are you using (go version)?
$ go version
go version go1.16.3 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/wzzhu/Library/Caches/go-build"
GOENV="/Users/wzzhu/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/wzzhu/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/wzzhu/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.16.3/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.16.3/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16.3"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/57/ntq8cyn57qq_2b532lr9cl_40000gn/T/go-build931250835=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
run the main.go above
What did you expect to see?
It should download the json file correctly.
What did you see instead?
It failed to download due to error in verifying the SSL certificate.
cat main.go
package main import ( "log" "net/http" ) func main() { if _, err := http.Get("https://www.1823.gov.hk/common/ical/sc.json"); err != nil { log.Fatalf("Error downloading HK calendar: %v", err) } } go run main.go Error downloading HK calendar: Get "https://www.1823.gov.hk/common/ical/sc.json": x509: certificate signed by unknown authorityThe simple http get to download a JSON through https protocol failed.
If tracing it down into the x509 package, will find that it does not find the right CA in SystemCertPool. But the CA is valid in Safari and it is valid in MacOS KeyChain's SystemRoots (in attached screen shot)
What version of Go are you using (
go version)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env)?go envOutputWhat did you do?
run the main.go above
What did you expect to see?
It should download the json file correctly.
What did you see instead?
It failed to download due to error in verifying the SSL certificate.