]> Cypherpunks repositories - gostls13.git/commit
crypto/tls: allow renegotiation to be handled by a client.
authorAdam Langley <agl@golang.org>
Tue, 26 Apr 2016 17:45:35 +0000 (10:45 -0700)
committerAdam Langley <agl@golang.org>
Thu, 28 Apr 2016 17:56:28 +0000 (17:56 +0000)
commitaf125a5193c75dd59307fcf1b26d885010ce8bfd
treee65c1ea478420bd8cb078911d96a0847f76018ab
parentd610d304f86021cc5f388b8f02d99bc73fca0d9b
crypto/tls: allow renegotiation to be handled by a client.

This change adds Config.Renegotiation which controls whether a TLS
client will accept renegotiation requests from a server. This is used,
for example, by some web servers that wish to “add” a client certificate
to an HTTPS connection.

This is disabled by default because it significantly complicates the
state machine.

Originally, handshakeMutex was taken before locking either Conn.in or
Conn.out. However, if renegotiation is permitted then a handshake may
be triggered during a Read() call. If Conn.in were unlocked before
taking handshakeMutex then a concurrent Read() call could see an
intermediate state and trigger an error. Thus handshakeMutex is now
locked after Conn.in and the handshake functions assume that Conn.in is
locked for the duration of the handshake.

Additionally, handshakeMutex used to protect Conn.out also. With the
possibility of renegotiation that's no longer viable and so
writeRecordLocked has been split off.

Fixes #5742.

Change-Id: I935914db1f185d507ff39bba8274c148d756a1c8
Reviewed-on: https://go-review.googlesource.com/22475
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
12 files changed:
src/crypto/tls/common.go
src/crypto/tls/conn.go
src/crypto/tls/handshake_client.go
src/crypto/tls/handshake_client_test.go
src/crypto/tls/handshake_messages.go
src/crypto/tls/handshake_server.go
src/crypto/tls/handshake_server_test.go
src/crypto/tls/testdata/Client-TLSv12-RenegotiateOnce [new file with mode: 0644]
src/crypto/tls/testdata/Client-TLSv12-RenegotiateTwice [new file with mode: 0644]
src/crypto/tls/testdata/Client-TLSv12-RenegotiateTwiceRejected [new file with mode: 0644]
src/crypto/tls/testdata/Client-TLSv12-RenegotiationRejected [new file with mode: 0644]
src/net/http/transport.go