Skip to content
Snippets Groups Projects
Commit 845c596a authored by Ion-Dorinel FILIP (25005)'s avatar Ion-Dorinel FILIP (25005)
Browse files

pep8 reformat

parent 050c90c3
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@ SERVER_CERT = './server.crt'
SERVER_PRIVATE = './server.key'
context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
#context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2) # Ubuntu 16.04
# context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2) # Ubuntu 16.04
context.load_cert_chain(SERVER_CERT, SERVER_PRIVATE)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
......@@ -18,7 +18,7 @@ sock.listen(5)
while True:
newsock, fromaddr = sock.accept()
ssock = context.wrap_socket(newsock, server_side=True)
data = ssock.recv(1024) # Read data over TLS
ssock.sendall(html.encode('utf-8')) # Send data over TLS
ssock.shutdown(socket.SHUT_RDWR) # Close the TLS connection
data = ssock.recv(1024) # Read data over TLS
ssock.sendall(html.encode('utf-8')) # Send data over TLS
ssock.shutdown(socket.SHUT_RDWR) # Close the TLS connection
ssock.close()
#!/usr/bin/python3
import socket, ssl, sys, pprint
# Primim ca argument hostname-ul serverului, de exemplu google.com
hostname = sys.argv[1]
......@@ -16,15 +17,15 @@ cadir = '/etc/ssl/certs'
# Set up the TLS context
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
#context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2) # For Ubuntu 16.04
# context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2) # For Ubuntu 16.04
context.load_verify_locations(capath=cadir)
context.verify_mode = ssl.CERT_REQUIRED
context.check_hostname = True
# Add the TLS
ssock = context.wrap_socket(sock, server_hostname=hostname,
do_handshake_on_connect=False)
ssock.do_handshake() # Start the handshake
do_handshake_on_connect=False)
ssock.do_handshake() # Start the handshake
pprint.pprint(ssock.getpeercert())
input("After handshake. Press any key to continue ...")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment