From 53ca9dda901c59489c3ca2b375a1a5ee8352907e Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Thu, 24 Jun 2021 17:03:35 +0200 Subject: [PATCH] simplify Server.sni, fix #4547 (#4660) --- mitmproxy/addons/tlsconfig.py | 2 +- mitmproxy/connection.py | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/mitmproxy/addons/tlsconfig.py b/mitmproxy/addons/tlsconfig.py index c20b6ee27..0fca4756f 100644 --- a/mitmproxy/addons/tlsconfig.py +++ b/mitmproxy/addons/tlsconfig.py @@ -171,7 +171,7 @@ class TlsConfig: else: verify = net_tls.Verify.VERIFY_PEER - if server.sni is True: + if server.sni is None: server.sni = client.sni or server.address[0] if not server.alpn_offers: diff --git a/mitmproxy/connection.py b/mitmproxy/connection.py index 190649ba2..41e5e7ddd 100644 --- a/mitmproxy/connection.py +++ b/mitmproxy/connection.py @@ -2,7 +2,7 @@ import uuid import warnings from abc import ABCMeta from enum import Flag -from typing import Literal, Optional, Sequence, Tuple, Union +from typing import Optional, Sequence, Tuple from mitmproxy import certs from mitmproxy.coretypes import serializable @@ -85,10 +85,9 @@ class Connection(serializable.Serializable, metaclass=ABCMeta): """Ciphers accepted by the proxy server on this connection.""" tls_version: Optional[str] = None """The active TLS version.""" - sni: Union[str, Literal[True], None] + sni: Optional[str] = None """ The [Server Name Indication (SNI)](https://en.wikipedia.org/wiki/Server_Name_Indication) sent in the ClientHello. - For server connections, this value may also be set to `True`, which means "use `Server.address`". """ timestamp_start: Optional[float] @@ -144,8 +143,6 @@ class Client(Connection): """ The certificate used by mitmproxy to establish TLS with the client. """ - sni: Union[str, None] = None - """The Server Name Indication sent by the client.""" timestamp_start: float """*Timestamp:* TCP SYN received""" @@ -272,7 +269,6 @@ class Server(Connection): timestamp_tcp_setup: Optional[float] = None """*Timestamp:* TCP ACK received.""" - sni: Union[str, Literal[True], None] = True via: Optional[server_spec.ServerSpec] = None """An optional proxy server specification via which the connection should be established."""