1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-01-08 21:18:00 +03:00

added fixes for ssl support on mac os

This commit is contained in:
admin 2023-05-12 14:11:29 +02:00
parent e42ab76088
commit ba28ab78ed
2 changed files with 15 additions and 2 deletions

View File

@ -267,3 +267,6 @@ def getCaCertsFile() -> typing.Optional[str]:
return path
return None
def isMac() -> bool:
return 'darwin' in sys.platform

View File

@ -119,7 +119,8 @@ class ForwardServer(socketserver.ThreadingTCPServer):
# Do not "recompress" data, use only "base protocol" compression
context.options |= ssl.OP_NO_COMPRESSION
context.minimum_version = ssl.TLSVersion.TLSv1_3
# On macs, seems to have problems with TLSv1.3, so we force TLSv1.2
context.minimum_version = ssl.TLSVersion.TLSv1_2 if tools.isMac() else ssl.TLSVersion.TLSv1_3
if tools.getCaCertsFile() is not None:
context.load_verify_locations(tools.getCaCertsFile()) # Load certifi certificates
@ -279,10 +280,19 @@ if __name__ == "__main__":
ticket = 'mffqg7q4s61fvx0ck2pe0zke6k0c5ipb34clhbkbs4dasb4g'
fs = forward(
('172.27.0.1', 7777),
('demoaslan.udsenterprise.com', 11443),
ticket,
local_port=0,
timeout=-20,
check_certificate=False,
)
print('Listening on port', fs.server_address)
import socket
# Open a socket to local fs.server_address and send some random data
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect(fs.server_address)
s.sendall(b'Hello world!')
data = s.recv(1024)
print('Received', repr(data))
fs.stop()