Skip to content

crypto/tls: wrong private key used for SNI connections #3367

@benburkert

Description

@benburkert
A client can use the server name indication TLS extension to specify the desired
hostname of the server certificate used in the TLS handshake. Go supports this SNI
extension in server connections with the tls.Config struct's NameToCertificate member
and BuildNameToCertificate function. These are used in the server connection's handshake
implementation to lookup a certificate which may not be the default certificate used by
the server. In such case, the key exchange functionality will still use the default
certificate's private key.

The linked code sample demonstrates this problem when the client recieve a "remote
error: bad record MAC" error during handshake. The included patch fixes this error
by keeping track of the non-default certificate's private key in the key exchange struct.

What steps will reproduce the problem?

https://gist.github.com/2151037

go run sni_test.go

What is the expected output?

the program should exit 0

What do you see instead?

a "remote error: bad record MAC" panic

Which compiler are you using (5g, 6g, 8g, gccgo)?

6g

Which operating system are you using?

OSX

Which revision are you using?  (hg identify)

15a98eba66e0

Please provide any additional information below.

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