Explorar o código

Fix: incorrect fix in 0d79dfc

Rod Hynes %!s(int64=10) %!d(string=hai) anos
pai
achega
cb9d0b35b0
Modificáronse 2 ficheiros con 9 adicións e 6 borrados
  1. 8 3
      psiphon/opensslConn.go
  2. 1 3
      psiphon/tlsDialer.go

+ 8 - 3
psiphon/opensslConn.go

@@ -97,9 +97,14 @@ func newOpenSSLConn(rawConn net.Conn, hostname string, config *CustomTLSConfig)
 	}
 	}
 
 
 	if config.SendServerName {
 	if config.SendServerName {
-		err = conn.SetTlsExtHostName(hostname)
-		if err != nil {
-			return nil, ContextError(err)
+		// Explicitly exclude IPs:
+		// - "Literal IPv4 and IPv6 addresses are not permitted": https://tools.ietf.org/html/rfc6066#page-6.
+		// - OpenSSL does not appear to enforce this rule itself.
+		if net.ParseIP(hostname) == nil {
+			err = conn.SetTlsExtHostName(hostname)
+			if err != nil {
+				return nil, ContextError(err)
+			}
 		}
 		}
 	}
 	}
 
 

+ 1 - 3
psiphon/tlsDialer.go

@@ -175,9 +175,7 @@ func CustomTLSDial(network, addr string, config *CustomTLSConfig) (net.Conn, err
 	if config.SendServerName && config.VerifyLegacyCertificate == nil {
 	if config.SendServerName && config.VerifyLegacyCertificate == nil {
 		// Set the ServerName and rely on the usual logic in
 		// Set the ServerName and rely on the usual logic in
 		// tls.Conn.Handshake() to do its verification.
 		// tls.Conn.Handshake() to do its verification.
-		// Explicitly exclude IPs:
-		// - "Literal IPv4 and IPv6 addresses are not permitted": https://tools.ietf.org/html/rfc6066#page-6.
-		// - OpenSSL does not appear to enforce this rule itself.
+		// Note: Go TLS will automatically omit this ServerName when it's an IP address
 		if net.ParseIP(hostname) == nil {
 		if net.ParseIP(hostname) == nil {
 			tlsConfig.ServerName = hostname
 			tlsConfig.ServerName = hostname
 		}
 		}