Fixes issue with tls handshake failing on some sites

This issue was caused because the ServerName property was not being set
when making tls requests

From the GO docs:
  ServerName is used to verify the hostname on the returned
  certificates unless InsecureSkipVerify is given. It is also included
  in the client's handshake to support virtual hosting unless it is
  an IP address.

https://pkg.go.dev/crypto/tls?tab=doc
This commit is contained in:
Jonathan Hodgson 2020-05-20 23:38:09 +01:00
parent aa1517a820
commit 62a4e44dc1
2 changed files with 4 additions and 0 deletions

View file

@ -416,6 +416,7 @@ func wsDial(req *ProxyRequest, useProxy bool, proxyHost string, proxyPort int, p
if req.DestUseTLS {
tls_conn := tls.Client(conn, &tls.Config{
InsecureSkipVerify: true,
ServerName: req.DestHost,
})
conn = tls_conn
}
@ -861,6 +862,7 @@ func submitRequest(req *ProxyRequest, useProxy bool, proxyHost string,
if req.DestUseTLS {
tls_conn := tls.Client(conn, &tls.Config{
InsecureSkipVerify: true,
ServerName: req.DestHost,
})
conn = tls_conn
}

View file

@ -242,6 +242,8 @@ func (pconn *proxyConn) StartMaybeTLS(hostname string) (bool, error) {
config := &tls.Config{
InsecureSkipVerify: true,
Certificates: []tls.Certificate{cert},
ServerName: hostname,
}
tlsConn := tls.Server(bufConn, config)
pconn.conn = tlsConn