23 lines
724 B
Python
23 lines
724 B
Python
import argparse
|
|
import json
|
|
import ssl
|
|
import socket
|
|
|
|
|
|
def run(parser: argparse.ArgumentParser, arguments: argparse.Namespace):
|
|
context = ssl.SSLContext(protocol=ssl.PROTOCOL_TLS_CLIENT)
|
|
context.load_verify_locations(arguments.certificate)
|
|
context.check_hostname = False
|
|
|
|
with (
|
|
socket.create_connection((arguments.hostname, arguments.port)) as sock_client,
|
|
context.wrap_socket(sock_client, server_hostname=arguments.hostname) as ssl_sock_client
|
|
):
|
|
data = {
|
|
"username": arguments.username,
|
|
"password": arguments.password,
|
|
"vote": arguments.vote,
|
|
}
|
|
|
|
ssl_sock_client.send(json.dumps(data).encode())
|
|
print("message sent.")
|