aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorThomas Kriechbaumer <Kriechi@users.noreply.github.com>2017-05-26 13:58:29 +0200
committerGitHub <noreply@github.com>2017-05-26 13:58:29 +0200
commitee6ea31147428729776ea2e8fe24d1fc44c63c9b (patch)
tree455ad7f40cc5dcbaf80ed8affd084bb33af274a7 /test
parente64aed02bd540948fe08f4de8af310d2ae1fae22 (diff)
parent9edfe1004b8cf02e12297670cd7db61eb4d0e2fd (diff)
downloadmitmproxy-ee6ea31147428729776ea2e8fe24d1fc44c63c9b.tar.gz
mitmproxy-ee6ea31147428729776ea2e8fe24d1fc44c63c9b.tar.bz2
mitmproxy-ee6ea31147428729776ea2e8fe24d1fc44c63c9b.zip
Merge pull request #2353 from ujjwal96/tls-parser
Using kaitai struct to parse tls client hello
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/contrib/test_tls_parser.py19
-rw-r--r--test/mitmproxy/proxy/protocol/test_tls.py3
2 files changed, 14 insertions, 8 deletions
diff --git a/test/mitmproxy/contrib/test_tls_parser.py b/test/mitmproxy/contrib/test_tls_parser.py
index 66972b62..e4d9177f 100644
--- a/test/mitmproxy/contrib/test_tls_parser.py
+++ b/test/mitmproxy/contrib/test_tls_parser.py
@@ -1,4 +1,6 @@
-from mitmproxy.contrib import tls_parser
+import io
+from kaitaistruct import KaitaiStream
+from mitmproxy.contrib.kaitaistruct import tls_client_hello
def test_parse_chrome():
@@ -12,18 +14,20 @@ def test_parse_chrome():
"00000000001200000010000e000c02683208687474702f312e3175500000000b00020100000a00080006001d00"
"170018"
)
- c = tls_parser.ClientHello.parse(data)
+
+ c = tls_client_hello.TlsClientHello(KaitaiStream(io.BytesIO(data)))
assert c.version.major == 3
assert c.version.minor == 3
alpn = [a for a in c.extensions.extensions if a.type == 16]
assert len(alpn) == 1
- assert alpn[0].alpn_protocols == [b"h2", b"http/1.1"]
+ assert alpn[0].body.alpn_protocols[0].name == b"h2"
+ assert alpn[0].body.alpn_protocols[1].name == b"http/1.1"
sni = [a for a in c.extensions.extensions if a.type == 0]
assert len(sni) == 1
- assert sni[0].server_names[0].name_type == 0
- assert sni[0].server_names[0].host_name == b"example.com"
+ assert sni[0].body.server_names[0].name_type == 0
+ assert sni[0].body.server_names[0].host_name == b"example.com"
def test_parse_no_extensions():
@@ -32,7 +36,8 @@ def test_parse_no_extensions():
"78e1bb6d22e8bbd5b6b0a3a59760ad354e91ba20d353001a0035002f000a000500040009000300060008006000"
"61006200640100"
)
- c = tls_parser.ClientHello.parse(data)
+
+ c = tls_client_hello.TlsClientHello(KaitaiStream(io.BytesIO(data)))
assert c.version.major == 3
assert c.version.minor == 1
- assert c.extensions is None
+ assert c.extensions == []
diff --git a/test/mitmproxy/proxy/protocol/test_tls.py b/test/mitmproxy/proxy/protocol/test_tls.py
index e17ee46f..980ba7bd 100644
--- a/test/mitmproxy/proxy/protocol/test_tls.py
+++ b/test/mitmproxy/proxy/protocol/test_tls.py
@@ -23,4 +23,5 @@ class TestClientHello:
)
c = TlsClientHello(data)
assert c.sni == 'example.com'
- assert c.alpn_protocols == [b'h2', b'http/1.1']
+ assert c.alpn_protocols[0].name == b'h2'
+ assert c.alpn_protocols[1].name == b'http/1.1'