python-proxy.py/no-ssl-wrap-socket.patch
2023-09-19 08:31:41 +00:00

63 lines
3.2 KiB
Diff

Index: proxy.py-2.4.3/proxy/core/connection/client.py
===================================================================
--- proxy.py-2.4.3.orig/proxy/core/connection/client.py
+++ proxy.py-2.4.3/proxy/core/connection/client.py
@@ -42,7 +42,8 @@ class TcpClientConnection(TcpConnection)
def wrap(self, keyfile: str, certfile: str) -> None:
self.connection.setblocking(True)
self.flush()
- self._conn = ssl.wrap_socket(
+ ssl_context = ssl.SSLContext(protocol=ssl.PROTOCOL_TLS_CLIENT)
+ self._conn = ssl_context.wrap_socket(
self.connection,
server_side=True,
certfile=certfile,
Index: proxy.py-2.4.3/tests/http/proxy/test_http_proxy_tls_interception.py
===================================================================
--- proxy.py-2.4.3.orig/tests/http/proxy/test_http_proxy_tls_interception.py
+++ proxy.py-2.4.3/tests/http/proxy/test_http_proxy_tls_interception.py
@@ -59,9 +59,9 @@ class TestHttpProxyTlsInterception(Asser
self.mock_ssl_context.return_value.wrap_socket.return_value = upstream_tls_sock
# Used for client wrapping
- self.mock_ssl_wrap = mocker.patch('ssl.wrap_socket')
+ self.mock_ssl_wrap = mocker.patch('ssl.SSLContext')
client_tls_sock = mock.MagicMock(spec=ssl.SSLSocket)
- self.mock_ssl_wrap.return_value = client_tls_sock
+ self.mock_ssl_wrap.return_value.wrap_socket.return_value = client_tls_sock
plain_connection = mock.MagicMock(spec=socket.socket)
@@ -249,6 +249,8 @@ class TestHttpProxyTlsInterception(Asser
)
assert self.flags.ca_cert_dir is not None
self.mock_ssl_wrap.assert_called_with(
+ protocol=ssl.PROTOCOL_TLS_CLIENT)
+ self.mock_ssl_wrap.return_value.wrap_socket.assert_called_with(
self._conn,
server_side=True,
keyfile=self.flags.ca_signing_key_file,
Index: proxy.py-2.4.3/tests/plugin/test_http_proxy_plugins_with_tls_interception.py
===================================================================
--- proxy.py-2.4.3.orig/tests/plugin/test_http_proxy_plugins_with_tls_interception.py
+++ proxy.py-2.4.3/tests/plugin/test_http_proxy_plugins_with_tls_interception.py
@@ -46,7 +46,7 @@ class TestHttpProxyPluginExamplesWithTls
'proxy.http.proxy.server.TcpServerConnection',
)
self.mock_ssl_context = mocker.patch('ssl.create_default_context')
- self.mock_ssl_wrap = mocker.patch('ssl.wrap_socket')
+ self.mock_ssl_wrap = mocker.patch('ssl.SSLContext')
self.mock_sign_csr.return_value = True
self.mock_gen_csr.return_value = True
@@ -80,7 +80,7 @@ class TestHttpProxyPluginExamplesWithTls
self.server_ssl_connection = mocker.MagicMock(spec=ssl.SSLSocket)
self.mock_ssl_context.return_value.wrap_socket.return_value = self.server_ssl_connection
self.client_ssl_connection = mocker.MagicMock(spec=ssl.SSLSocket)
- self.mock_ssl_wrap.return_value = self.client_ssl_connection
+ self.mock_ssl_wrap.return_value.wrap_socket.return_value = self.client_ssl_connection
def has_buffer() -> bool:
return cast(bool, self.server.queue.called)