Skip to content

Instantly share code, notes, and snippets.

@parsibox
Created June 8, 2023 13:50
Show Gist options
  • Save parsibox/298a34ea19940ffd1c8571e4bc2e6429 to your computer and use it in GitHub Desktop.
Save parsibox/298a34ea19940ffd1c8571e4bc2e6429 to your computer and use it in GitHub Desktop.
go lang https fix handshake error
package main
import (
"crypto/tls"
"fmt"
"log"
"net/http"
"time"
)
func main() {
client := &http.Client{
Timeout: 10 * time.Second,
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
MinVersion: tls.VersionTLS12,
CipherSuites: []uint16{
tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
},
},
},
}
req, err := http.NewRequest("GET", "https://www.google.com/", nil)
if err != nil {
log.Fatalf("%s\n", err)
}
resp, err := client.Do(req)
if err != nil {
log.Fatalf("%s\n", err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment