Skip to content

Instantly share code, notes, and snippets.

@leeyoungseok
Created August 18, 2020 22:52
Show Gist options
  • Save leeyoungseok/6fe36892735057296f1746b1398cc28e to your computer and use it in GitHub Desktop.
Save leeyoungseok/6fe36892735057296f1746b1398cc28e to your computer and use it in GitHub Desktop.
import socket, ssl, pprint
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ssock = ssl.wrap_socket(s,
ca_certs="server.crt", cert_reqs = ssl.CERT_REQUIRED)
ssock.connect(('localhost', 12345))
print(repr(ssock.getpeername()))
print(ssock.cipher())
print(pprint.pformat(ssock.getpeername()))
msg = input('Type the message: ')
msg = msg.encode('utf-8')
ssock.sendall(msg)
data = ssock.recv(1500)
print('Echoed {0}'.format(data.decode('utf-8')))
ssock.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment