Skip to content

Commit

Permalink
Use hostname to match ssl cert (#76)
Browse files Browse the repository at this point in the history
Co-authored-by: Petr Nuzhnov <[email protected]>
  • Loading branch information
Nuzhnov and Petr Nuzhnov authored Nov 16, 2023
1 parent f729eb9 commit b3c1b89
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ch_tools/monrun_checks_keeper/keeper_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
CH_DBMS_DEFAULT_PATH = "/var/lib/clickhouse/snapshots"

context = ssl.create_default_context()
context.minimum_version = ssl.TLSVersion.TLSv1_2


@command("alive")
Expand Down Expand Up @@ -208,12 +209,12 @@ def keeper_command(cmd, timeout, verify_ssl_certs):
if not verify_ssl_certs:
context.check_hostname = False
context.verify_mode = ssl.CERT_NONE
with context.wrap_socket(sock, server_hostname="localhost") as ssock:
ssock.connect(("localhost", port))
with context.wrap_socket(sock, server_hostname=socket.getfqdn()) as ssock:
ssock.connect(("127.0.0.1", port))
ssock.sendall(cmd.encode())
return ssock.makefile().read(-1)
else:
sock.connect(("localhost", port))
sock.connect(("127.0.0.1", port))
sock.sendall(cmd.encode())
return sock.makefile().read(-1)

Expand Down

0 comments on commit b3c1b89

Please sign in to comment.