Skip to content

Commit fb5ffc3

Browse files
author
Alex Gaetano Padula
committed
TLS connectivity
1 parent 65d68db commit fb5ffc3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

cursusdb-py/main.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ def __init__(self, host, port, username, password, tls):
3232

3333
# Instance method
3434
def connect(self):
35+
if self.tls:
36+
context = ssl.create_default_context()
37+
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
38+
self.sock = context.wrap_socket(socket.socket(socket.AF_INET), server_hostname=self.host)
39+
3540
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
3641
self.sock.connect((self.host, self.port))
3742
auth_str = f"{self.username}\\0{self.password}".encode("utf8")

0 commit comments

Comments
 (0)