Skip to content

crypto/tls: Conn.ConnectionState should set state.ServerName from c.serverName unconditionally - handshakeComplete is not necessary for SNI #15571

Description

@amalaviy

Please answer these questions before submitting your issue. Thanks!

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

go1.6.1

  1. What operating system and processor architecture are you using (go env)?
    GOARCH="amd64"
    GOBIN=""
    GOEXE=""
    GOHOSTARCH="amd64"
    GOHOSTOS="linux"
    GOOS="linux"
  2. What did you do?

Called c.ConnectionState() on a connection that failed Handshake() intentionally. c.serverName is set correctly, but ConnectionState() doesn't copy it over to state.ServerName due to unnecessary check for handshakeComplete. SNI is plaintext, it does not need to check for handshakeComplete - it is available even on failure and is purely a TLS clientHello field and is useful to have available for logging.

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

  1. What did you expect to see?
    c.ConnectionState().ServerName to be filled with the SNI set by the tls client.
  2. What did you see instead?
    c.Connectionstate().ServerName == ""

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions