Alternative TLS implementation in Go
Go to file
Adam Langley 2680804ebc crypto/tls: enforce that either ServerName or InsecureSkipVerify be given.
crypto/tls has two functions for creating a client connection: Dial,
which most users are expected to use, and Client, which is the
lower-level API.

Dial does what you expect: it gives you a secure connection to the host
that you specify and the majority of users of crypto/tls appear to work
fine with it.

Client gives more control but needs more care. Specifically, if it
wasn't given a server name in the tls.Config then it didn't check that
the server's certificates match any hostname - because it doesn't have
one to check against. It was assumed that users of the low-level API
call VerifyHostname on the certificate themselves if they didn't supply
a hostname.

A review of the uses of Client both within Google and in a couple of
external libraries has shown that nearly all of them got this wrong.

Thus, this change enforces that either a ServerName or
InsecureSkipVerify is given. This does not affect tls.Dial.

See discussion at https://groups.google.com/d/msg/golang-nuts/4vnt7NdLvVU/b1SJ4u0ikb0J.

Fixes #7342.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/67010043
2014-02-21 15:56:41 -05:00
testdata crypto/tls: support renegotiation extension. 2014-01-09 13:38:11 -05:00
alert.go crypto/tls: add Error method to alert 2011-10-27 19:42:32 -07:00
cipher_suites.go crypto/tls: don't select TLS 1.2 cipher suites in prior versions. 2013-09-26 17:09:56 -04:00
common.go crypto/tls: improve documentation for ServerName. 2014-02-19 11:17:09 -05:00
conn_test.go crypto/tls: add server side SNI support. 2011-10-08 10:06:53 -04:00
conn.go crypto/tls: better error messages. 2014-02-12 11:20:01 -05:00
example_test.go crypto/x509: add example of using a custom root list. 2014-02-19 11:18:35 -05:00
generate_cert.go crypto/tls: generate random serial numbers. 2013-12-15 12:57:57 -05:00
handshake_client_test.go crypto/tls: Client side support for TLS session resumption. 2014-01-22 18:24:03 -05:00
handshake_client.go crypto/tls: enforce that either ServerName or InsecureSkipVerify be given. 2014-02-21 15:56:41 -05:00
handshake_messages_test.go crypto/tls: advertise support for RSA+SHA1 in TLS 1.2 handshake. 2013-10-21 16:35:09 -04:00
handshake_messages.go crypto/tls: support renegotiation extension. 2014-01-09 13:38:11 -05:00
handshake_server_test.go crypto/tls: better error messages. 2014-02-12 11:20:01 -05:00
handshake_server.go crypto/tls: better error messages. 2014-02-12 11:20:01 -05:00
handshake_test.go crypto/tls: rework reference tests. 2013-12-20 11:37:05 -05:00
key_agreement.go crypto/tls: better error messages. 2014-02-12 11:20:01 -05:00
prf_test.go crypto/tls: support TLS 1.1. 2013-06-04 20:02:22 -04:00
prf.go crypto/tls: fix TLS 1.2 client certificates. 2013-09-16 16:39:42 -04:00
ticket.go crypto/tls: support session ticket resumption. 2012-09-24 16:52:43 -04:00
tls_test.go crypto/tls: fix loading keys labeled just "PRIVATE KEY" 2012-12-01 11:02:08 -08:00
tls.go crypto/tls: improve documentation for ServerName. 2014-02-19 11:17:09 -05:00