MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / parse_client_hello

Function parse_client_hello

mitmproxy/proxy/layers/tls.py:72–91  ·  view source on GitHub ↗

Check if the supplied bytes contain a full ClientHello message, and if so, parse it. Returns: - A ClientHello object on success - None, if the TLS record is not complete Raises: - A ValueError, if the passed ClientHello is invalid

(data: bytes)

Source from the content-addressed store, hash-verified

70
71
72def parse_client_hello(data: bytes) -> ClientHello | None:
73 """
74 Check if the supplied bytes contain a full ClientHello message,
75 and if so, parse it.
76
77 Returns:
78 - A ClientHello object on success
79 - None, if the TLS record is not complete
80
81 Raises:
82 - A ValueError, if the passed ClientHello is invalid
83 """
84 # Check if ClientHello is complete
85 client_hello = get_client_hello(data)
86 if client_hello:
87 try:
88 return ClientHello(client_hello[4:])
89 except EOFError as e:
90 raise ValueError("Invalid ClientHello") from e
91 return None
92
93
94def dtls_handshake_record_contents(data: bytes) -> Iterator[bytes]:

Callers 3

_get_client_helloMethod · 0.90

Calls 2

ClientHelloClass · 0.90
get_client_helloFunction · 0.85

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…