-
-
Notifications
You must be signed in to change notification settings - Fork 601
/
Copy pathssl_echo_client.py
42 lines (36 loc) · 1.23 KB
/
ssl_echo_client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# -*- coding: utf-8 -*-
"""
proxy.py
~~~~~~~~
⚡⚡⚡ Fast, Lightweight, Pluggable, TLS interception capable proxy server focused on
Network monitoring, controls & Application development, testing, debugging.
:copyright: (c) 2013-present by Abhinav Singh and contributors.
:license: BSD, see LICENSE for more details.
"""
import ssl
import logging
from proxy.core.connection import TcpServerConnection
from proxy.common.constants import DEFAULT_LOG_FORMAT, DEFAULT_BUFFER_SIZE
logging.basicConfig(level=logging.INFO, format=DEFAULT_LOG_FORMAT)
logger = logging.getLogger(__name__)
if __name__ == '__main__':
client = TcpServerConnection('127.0.0.1', 12345)
client.connect()
client.wrap(
None, # 'localhost',
ca_file='ca-cert.pem',
# For self-signed certs you will have
# to disable verification. Or you can
# add your CA certificate in the CA bundle
# and then enable verify.
verify_mode=ssl.VerifyMode.CERT_NONE,
)
try:
while True:
client.send(b'hello')
data = client.recv(DEFAULT_BUFFER_SIZE)
if data is None:
break
logger.info(data.tobytes())
finally:
client.close()