Skip to content

crypto/tls: cipher suite configuration is ignored breaking existing code #31072

Closed
@4a6f656c

Description

@4a6f656c

What version of Go are you using (go version)?

$ go version
go version devel +724a86fced Wed Mar 27 02:37:56 2019 +0000 openbsd/amd64

What did you do?

package main

import (
        "crypto/tls"
        "log"
)

func main() {
        tlsCfg := &tls.Config{
                CipherSuites: []uint16{tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256},
                //MaxVersion: tls.VersionTLS12,
                ServerName: "www.cloudflare.com",
        }

        conn, err := tls.Dial("tcp", "www.cloudflare.com:443", tlsCfg)
        if err != nil {
                log.Fatalf("Failed to dial: %v", err)
        }
        defer conn.Close()

        cs := conn.ConnectionState()
        log.Printf("Connected with TLS 0x%x using cipher suite 0x%x\n", cs.Version, cs.CipherSuite)
}

What did you expect to see?

Connected with TLS 0x303 using cipher suite 0xc02f

(which is what occurs if compiled with Go 1.12)

What did you see instead?

Connected with TLS 0x304 using cipher suite 0x1301

Based on the crypto/tls code and documentation for crypto/tls.Config, this is an intentional change, however it changes the behaviour of existing code - previously when compiled and run it would adhere to the configuration in CipherSuites, however it is now silently ignored and the behaviour changes to one that is not intended by the author.

This means that the connection is potentially being established without using one of the intended cipher suites - there are various cases where this is a bad thing. Obviously it can be worked around by pinning the maximum version (i.e. uncommenting the MaxVersion in the above code), however this still requires a change to existing code and is probably worse than having pinned cipher suites.

I'm also somewhat concerned by the fact that there is no way to configure the cipher suites for TLS 1.3.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions