Skip to content

Commit

Permalink
Merge pull request #21 from buffrr/tls-improvements
Browse files Browse the repository at this point in the history
TLS improvements
  • Loading branch information
buffrr authored May 16, 2022
2 parents 4a11faf + 2258e51 commit 3aca8ab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
13 changes: 13 additions & 0 deletions tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ func newTLSConfig(host string, rrs []*dns.TLSA, nameCheck bool) *tls.Config {
VerifyConnection: verifyConnection(rrs, nameCheck),
ServerName: host,
MinVersion: tls.VersionTLS12,
// Supported TLS 1.2 cipher suites
// Crypto package does automatic cipher suite ordering
CipherSuites: []uint16{
tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
tls.TLS_AES_128_GCM_SHA256,
tls.TLS_AES_256_GCM_SHA384,
tls.TLS_CHACHA20_POLY1305_SHA256,
},
}
}

Expand Down
4 changes: 3 additions & 1 deletion tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ func (h *tunneler) Tunnel(ctx context.Context, clientConn *proxy.Conn, network,
// used by the remote server
clientTLSConfig := h.mitm.configForTLSADomain(tlsaDomain)
if alpn {
clientTLSConfig.NextProtos = []string{remote.ConnectionState().NegotiatedProtocol}
if serverProto := remote.ConnectionState().NegotiatedProtocol; serverProto != "" {
clientTLSConfig.NextProtos = []string{serverProto}
}
}

clientTLS := tls.Server(clientConn, clientTLSConfig)
Expand Down

0 comments on commit 3aca8ab

Please sign in to comment.