golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
120.91k stars 17.35k forks source link

x/net/http2: tls: handshake failure with site that does not support HTTP2 #66998

Open araby-deepsky opened 2 months ago

araby-deepsky commented 2 months ago

This simple program fails to fetch JSON over https with

Error Get "https://www.hydroquebec.com/data/documents-donnees/donnees-ouvertes/json/demande.json": remote error: tls: handshake failure

package main

import (
    "fmt"
    "net/http"
)

const SRC_URL = "https://www.hydroquebec.com/data/documents-donnees/donnees-ouvertes/json/demande.json"

func main() {
    //lambda.Start(handler)
    fmt.Println("Start fetching from ", SRC_URL)

    // Send HTTP GET request to the URL

    resp, err := http.Get(SRC_URL)
    if err != nil {
        fmt.Println("Error", err)
    } else {
        fmt.Println("Response", resp)
    }

}

With GO 1.22.2


% go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/Users/araby/Library/Caches/go-build'
GOENV='/Users/araby/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/araby/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/araby/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/Cellar/go/1.22.2/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/Cellar/go/1.22.2/libexec/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='go1.22.2'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/araby/git/deep_sky/electricity-emission-factor-hq/fetchUrl/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/13/8cy89d656xj3tt4wxwgthh480000gn/T/go-build806880367=/tmp/go-build -gno-record-gcc-switches -fno-common'
araby@Annes-MacBook-Pro fetchUrl %
``` `
araby-deepsky commented 2 months ago

The target site www.hydroquebec.com supports neither HTTP/2 nor ALPN