Adjust for new get_remote_cert API.

This commit is contained in:
Aldo Cortesi 2012-06-28 10:02:14 +12:00
parent 35ee0c098f
commit 243e0efefc
3 changed files with 6 additions and 5 deletions

View File

@ -1,3 +1,3 @@
[report] [report]
omit = *contrib*, *tnetstring* omit = *contrib*, *tnetstring*, *platform*
include = *libmproxy* include = *libmproxy*

View File

@ -198,6 +198,7 @@ class Request(HTTPMsg):
path: Path portion of the URL path: Path portion of the URL
timestamp: Seconds since the epoch timestamp: Seconds since the epoch
method: HTTP method method: HTTP method
""" """
def __init__(self, client_conn, httpversion, host, port, scheme, method, path, headers, content, timestamp=None): def __init__(self, client_conn, httpversion, host, port, scheme, method, path, headers, content, timestamp=None):

View File

@ -193,13 +193,13 @@ class ProxyHandler(tcp.BaseHandler):
else: else:
return True return True
def find_cert(self, host, port): def find_cert(self, host, port, sni):
if self.config.certfile: if self.config.certfile:
return self.config.certfile return self.config.certfile
else: else:
sans = [] sans = []
if self.config.upstream_cert: if self.config.upstream_cert:
cert = certutils.get_remote_cert(host, port) cert = certutils.get_remote_cert(host, port, sni)
sans = cert.altnames sans = cert.altnames
host = cert.cn host = cert.cn
ret = certutils.dummy_cert(self.config.certdir, self.config.cacert, host, sans) ret = certutils.dummy_cert(self.config.certdir, self.config.cacert, host, sans)
@ -225,7 +225,7 @@ class ProxyHandler(tcp.BaseHandler):
host, port = self.config.transparent_proxy["resolver"].original_addr(self.connection) host, port = self.config.transparent_proxy["resolver"].original_addr(self.connection)
if not self.ssl_established and (port in self.config.transparent_proxy["sslports"]): if not self.ssl_established and (port in self.config.transparent_proxy["sslports"]):
scheme = "https" scheme = "https"
certfile = self.find_cert(host, port) certfile = self.find_cert(host, port, None)
self.convert_to_ssl(certfile, self.config.certfile or self.config.cacert) self.convert_to_ssl(certfile, self.config.certfile or self.config.cacert)
else: else:
scheme = "http" scheme = "http"
@ -274,7 +274,7 @@ class ProxyHandler(tcp.BaseHandler):
'\r\n' '\r\n'
) )
self.wfile.flush() self.wfile.flush()
certfile = self.find_cert(host, port) certfile = self.find_cert(host, port, None)
self.convert_to_ssl(certfile, self.config.certfile or self.config.cacert) self.convert_to_ssl(certfile, self.config.certfile or self.config.cacert)
self.proxy_connect_state = (host, port, httpversion) self.proxy_connect_state = (host, port, httpversion)
line = self.rfile.readline(line) line = self.rfile.readline(line)