aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/protocol2
diff options
context:
space:
mode:
authorThomas Kriechbaumer <thomas@kriechbaumer.name>2015-08-15 17:43:46 +0200
committerThomas Kriechbaumer <thomas@kriechbaumer.name>2015-08-15 17:49:40 +0200
commita9dd82c986be54d82f6ce9c7b65473f2b052cbe8 (patch)
treee284eeeec9674d5eb53714cf0944bb8db89dfe75 /libmproxy/protocol2
parent747699b126ab5788aca4541c9c9b4608611e7efa (diff)
downloadmitmproxy-a9dd82c986be54d82f6ce9c7b65473f2b052cbe8.tar.gz
mitmproxy-a9dd82c986be54d82f6ce9c7b65473f2b052cbe8.tar.bz2
mitmproxy-a9dd82c986be54d82f6ce9c7b65473f2b052cbe8.zip
add ALPN to proxy connections
Diffstat (limited to 'libmproxy/protocol2')
-rw-r--r--libmproxy/protocol2/http_proxy.py3
-rw-r--r--libmproxy/protocol2/tls.py8
2 files changed, 9 insertions, 2 deletions
diff --git a/libmproxy/protocol2/http_proxy.py b/libmproxy/protocol2/http_proxy.py
index 51d3763c..b85a65eb 100644
--- a/libmproxy/protocol2/http_proxy.py
+++ b/libmproxy/protocol2/http_proxy.py
@@ -1,7 +1,6 @@
from __future__ import (absolute_import, print_function, division)
from .layer import Layer, ServerConnectionMixin
-from .http import HttpLayer
class HttpProxy(Layer, ServerConnectionMixin):
@@ -22,3 +21,5 @@ class HttpUpstreamProxy(Layer, ServerConnectionMixin):
for message in layer():
if not self._handle_server_message(message):
yield message
+
+from .http import HttpLayer
diff --git a/libmproxy/protocol2/tls.py b/libmproxy/protocol2/tls.py
index 988304aa..9572912f 100644
--- a/libmproxy/protocol2/tls.py
+++ b/libmproxy/protocol2/tls.py
@@ -1,7 +1,9 @@
from __future__ import (absolute_import, print_function, division)
import traceback
+
from netlib import tcp
+import netlib.http.http2
from ..exceptions import ProtocolException
from .layer import Layer, yield_from_callback
@@ -147,7 +149,8 @@ class TlsLayer(Layer):
handle_sni=self.__handle_sni,
cipher_list=self.config.ciphers_client,
dhparams=self.config.certstore.dhparams,
- chain_file=chain_file
+ chain_file=chain_file,
+ alpn_select=netlib.http.http2.HTTP2Protocol.ALPN_PROTO_H2, # TODO: check if server is capable of h2 first
)
except tcp.NetLibError as e:
raise ProtocolException(repr(e), e)
@@ -164,6 +167,9 @@ class TlsLayer(Layer):
ca_path=self.config.openssl_trusted_cadir_server,
ca_pemfile=self.config.openssl_trusted_ca_server,
cipher_list=self.config.ciphers_server,
+ alpn_protos=[
+ netlib.http.http1.HTTP1Protocol.ALPN_PROTO_HTTP1,
+ netlib.http.http2.HTTP2Protocol.ALPN_PROTO_H2], # TODO: read this from client_conn first
)
tls_cert_err = self.server_conn.ssl_verification_error
if tls_cert_err is not None: