Fix bug that caused mis-identification of some HTTPS connections in transparent mode.

This commit is contained in:
Aldo Cortesi 2013-03-17 14:35:36 +13:00
parent 87f76bb62b
commit 790ad468e4
1 changed files with 11 additions and 10 deletions

View File

@ -323,17 +323,18 @@ class ProxyHandler(tcp.BaseHandler):
if not orig: if not orig:
raise ProxyError(502, "Transparent mode failure: could not resolve original destination.") raise ProxyError(502, "Transparent mode failure: could not resolve original destination.")
host, port = orig host, port = orig
if not self.ssl_established and (port in self.config.transparent_proxy["sslports"]): if port in self.config.transparent_proxy["sslports"]:
scheme = "https" scheme = "https"
dummycert = self.find_cert(client_conn, host, port, host) if not self.ssl_established:
sni = HandleSNI( dummycert = self.find_cert(client_conn, host, port, host)
self, client_conn, host, port, sni = HandleSNI(
dummycert, self.config.certfile or self.config.cacert self, client_conn, host, port,
) dummycert, self.config.certfile or self.config.cacert
try: )
self.convert_to_ssl(dummycert, self.config.certfile or self.config.cacert, handle_sni=sni) try:
except tcp.NetLibError, v: self.convert_to_ssl(dummycert, self.config.certfile or self.config.cacert, handle_sni=sni)
raise ProxyError(400, str(v)) except tcp.NetLibError, v:
raise ProxyError(400, str(v))
else: else:
scheme = "http" scheme = "http"
line = self.get_line(self.rfile) line = self.get_line(self.rfile)