Add more debug info and error handling to ssltest
This commit is contained in:
parent
ff593273bf
commit
6247e1d3ea
|
@ -2,6 +2,7 @@ import select
|
||||||
import socket
|
import socket
|
||||||
import ssl
|
import ssl
|
||||||
import sys
|
import sys
|
||||||
|
import traceback
|
||||||
|
|
||||||
HOST = "127.0.0.1"
|
HOST = "127.0.0.1"
|
||||||
PORT = 8912
|
PORT = 8912
|
||||||
|
@ -55,7 +56,8 @@ def sslHandshake(sock, server=False):
|
||||||
print "Waiting for SSL socket handhake write"
|
print "Waiting for SSL socket handhake write"
|
||||||
select.select([], [self.sslSock], [], 10)
|
select.select([], [self.sslSock], [], 10)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print "SSL socket handhake failed, shutting down connection: %s" % (e)
|
print "SSL socket handhake failed, shutting down connection"
|
||||||
|
traceback.print_exc()
|
||||||
return
|
return
|
||||||
print "Success!"
|
print "Success!"
|
||||||
return sslSock
|
return sslSock
|
||||||
|
@ -71,13 +73,15 @@ if __name__ == "__main__":
|
||||||
sock, addr = serversock.accept()
|
sock, addr = serversock.accept()
|
||||||
print "Got connection from %s:%i" % (addr[0], addr[1])
|
print "Got connection from %s:%i" % (addr[0], addr[1])
|
||||||
sslSock = sslHandshake(sock, True)
|
sslSock = sslHandshake(sock, True)
|
||||||
sslSock.shutdown(socket.SHUT_RDWR)
|
if sslSock:
|
||||||
sslSock.close()
|
sslSock.shutdown(socket.SHUT_RDWR)
|
||||||
|
sslSock.close()
|
||||||
elif sys.argv[1] == "client":
|
elif sys.argv[1] == "client":
|
||||||
sock = connect()
|
sock = connect()
|
||||||
sslSock = sslHandshake(sock, False)
|
sslSock = sslHandshake(sock, False)
|
||||||
sslSock.shutdown(socket.SHUT_RDWR)
|
if sslSock:
|
||||||
sslSock.close()
|
sslSock.shutdown(socket.SHUT_RDWR)
|
||||||
|
sslSock.close()
|
||||||
else:
|
else:
|
||||||
print "Usage: ssltest.py client|server"
|
print "Usage: ssltest.py client|server"
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user