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.