Advertisement
toko214

sslClient

Jan 15th, 2017
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. import socket, ssl, pprint
  2.  
  3. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  4.  
  5. # Require a certificate from the server. We used a self-signed certificate
  6. # so here ca_certs must be the server certificate itself.
  7. ssl_sock = ssl.wrap_socket(s,
  8.                            ca_certs="mycert.cert",
  9.                            cert_reqs=ssl.CERT_REQUIRED)
  10.  
  11. ssl_sock.connect(('127.0.0.1', 8200))
  12. ssl_sock.write("boo!")
  13. msg = ssl_sock.read()
  14.  
  15. print(msg)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement