serverConfig presents a certificate for the host gh names in its TLS handshake, or for fallback when it names none.
(fallback string)
| 112 | // serverConfig presents a certificate for the host gh names in its TLS |
| 113 | // handshake, or for fallback when it names none. |
| 114 | func (ca *certAuthority) serverConfig(fallback string) *tls.Config { |
| 115 | return &tls.Config{ |
| 116 | MinVersion: tls.VersionTLS12, |
| 117 | // The server inside the tunnel speaks HTTP/1.1 only. |
| 118 | NextProtos: []string{"http/1.1"}, |
| 119 | GetCertificate: func(hello *tls.ClientHelloInfo) (*tls.Certificate, error) { |
| 120 | host := hello.ServerName |
| 121 | if host == "" { |
| 122 | host = fallback |
| 123 | } |
| 124 | return ca.leaf(host) |
| 125 | }, |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | // bufferedConn reads first whatever the CONNECT request's reader buffered, |
| 130 | // which can include the start of the TLS handshake. |