【问题标题】:ssl version and cipher suites of the client客户端的 ssl 版本和密码套件
【发布时间】:2018-07-07 23:00:02
【问题描述】:

我正在开发一个肥皂服务器,它将为一些使用旧版肥皂协议的旧嵌入式计算机提供服务。

我在 go 中编写它,到目前为止只使用普通的http,但在生产中它必须使用ssl 加密。所以我刚刚创建了一个密钥和一个证书(来自this site)并使用了http.ListenAndServeTLS 函数。

但现在计算机无法连接,服务器只是打印握手错误:

server.go:2848: http: TLS handshake error from [::1]:38790: tls: no cipher suite supported by both client and server

在文档中,对于计算机,不是受支持的 ssl 版本或密码。所以我想知道,如何找出客户端的 ssl 版本,以及客户端支持的可用密码套件。

然后如何配置 golang http 服务器,使其支持所选密码。

【问题讨论】:

    标签: ssl go https


    【解决方案1】:

    这里似乎有两个问题,所以我们分两部分来做:

    查找客户端的 TLS 版本和支持的密码套件:

    为此,您需要设置tls.Config 对象的GetConfigForClient 字段。

    该字段采用带签名的方法:

    func(*ClientHelloInfo) (*Config, error)
    

    在收到带有ClientHelloInfo 结构的Client Hello 消息时调用它。此结构包含您感兴趣的以下字段:

        // CipherSuites lists the CipherSuites supported by the client (e.g.
        // TLS_RSA_WITH_RC4_128_SHA).
        CipherSuites []uint16
    
        // SupportedVersions lists the TLS versions supported by the client.
        // For TLS versions less than 1.3, this is extrapolated from the max
        // version advertised by the client, so values other than the greatest
        // might be rejected if used.
        SupportedVersions []uint16
    

    请阅读 GetConfigForClientClientHelloInfo 周围的 cmets,了解 GetConfigForClient 的确切行为方式以及字段详细信息。

    指定服务器支持的版本和密码套件:

    这也可以通过tls.Config 对象使用以下字段来完成:

        // CipherSuites is a list of supported cipher suites. If CipherSuites
        // is nil, TLS uses a list of suites supported by the implementation.
        CipherSuites []uint16
    
        // MinVersion contains the minimum SSL/TLS version that is acceptable.
        // If zero, then TLS 1.0 is taken as the minimum.
        MinVersion uint16
    
        // MaxVersion contains the maximum SSL/TLS version that is acceptable.
        // If zero, then the maximum version supported by this package is used,
        // which is currently TLS 1.2.
        MaxVersion uint16
    

    例如,您可以使用以下字段设置 tls.Config:

        CipherSuites: []uint16{
            tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
            tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
            tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
            etc...
            tls.TLS_RSA_WITH_AES_256_CBC_SHA,
        },
    
        MinVersion: tls.VersionTLS12,
    

    支持的密码套件的完整列表位于tls docs

    【讨论】:

    • 太好了,谢谢。所以我发现它支持:TLS_RSA_WITH_AES_256_CBC_SHA TLS_RSA_WITH_3DES_EDE_CBC_SHA TLS_RSA_WITH_AES_128_CBC_SHA TLS_RSA_WITH_RC4_128_SHA。将 thede 添加到 CipherSuites 并没有帮助。我必须创建一个RSA 密钥/证书?
    • 您确实需要服务器证书和密钥。这些通常与 RSA 兼容以实现兼容性。如果这是面向公众的服务器,最简单的方法是使用 Let's Encrypt。
    • 我已经使用openssl 创建了密钥(刚刚从this 站点复制了命令)。但是刚才我终于明白第二个命令(openssl ecparam -genkey -name secp384r1 -out server.key)创建了ECDSA 键,而不是RSA 键。所以我创建了一个新的RSA 密钥,现在一切正常,谢谢!
    • @microo8:那些密码套件看起来像 SSL,椭圆曲线 diffie-hellman 更像是 TLS 的东西。你绝对不应该使用 SSL,甚至 TLS 1.0。
    • SupportedVersions是支持TLS1.0所以我觉得还可以
    猜你喜欢
    • 2015-07-14
    • 2017-04-12
    • 2016-02-27
    • 1970-01-01
    • 2017-06-12
    • 1970-01-01
    • 2014-08-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多