ssl - Golang http客户端握手失败

标签 ssl go https handshake

尝试获取网页:

    tr := &http.Transport{
        TLSHandshakeTimeout: 30 * time.Second,
        DisableKeepAlives: true,
    }

    client := &http.Client{Transport: tr}

    req, err := http.NewRequest("GET", "https://www.fl.ru/", 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()

获取https://www.fl.ru/ :远程错误:握手失败。

如果我尝试获取另一个 HTTPS 页面 - 一切正常。

最佳答案

该服务器仅支持一些弱密码:

TLS_DHE_RSA_WITH_AES_256_CBC_SHA (0x39)   DH 1024 bits (p: 128, g: 1, Ys: 128)   FS   WEAK
TLS_DHE_RSA_WITH_AES_128_CBC_SHA (0x33)   DH 1024 bits (p: 128, g: 1, Ys: 128)   FS   WEAK
TLS_RSA_WITH_RC4_128_SHA (0x5)   WEAK

如果你真的必须连接到那个服务器,Go 确实支持列表中的最后一个密码,但默认情况下不支持。使用新的 tls.Config 创建一个客户端,指定您想要的密码:

t := &http.Transport{
    Proxy: http.ProxyFromEnvironment,
    Dial: (&net.Dialer{
        Timeout:   30 * time.Second,
        KeepAlive: 30 * time.Second,
    }).Dial,
    TLSHandshakeTimeout: 10 * time.Second,
    TLSClientConfig: &tls.Config{
        CipherSuites: []uint16{tls.TLS_RSA_WITH_RC4_128_SHA},
    },
}

关于ssl - Golang http客户端握手失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32523521/

相关文章:

asp.net-mvc-3 - SSL 证书将加密我的 MVC 3 应用程序中使用的查询字符串值

PHPMailer 不适用于 gmail

security - X.509 DN 的所有部分都是可选的吗?

go - 这是在golang中的类型转换吗?

google-app-engine - 在 GAE 中,用户什么时候可能没有 ID

python - 为什么这个 Python 代码不能通过 SSL 连接?

Mongodb不会使用游标检索具有200万条记录的集合中的所有文档

java - jetty "javax.net.ssl.SSLHandshakeException: no cipher suites in common"

SSL 和绿色 https

javascript - 如何与本地主机上的 websocket 建立安全连接?