SSLError(): use errno with int-comparison instead of str().startswith()-comparison

incoming
mcfreis 2017-03-17 15:31:59 +01:00
parent ba51e0bbcd
commit 1c7bdcad16
1 changed files with 5 additions and 5 deletions

View File

@ -46,8 +46,8 @@ def main():
cert_path = path.join(path.abspath(path.dirname(__file__)), "certs")
scn = SSLConnection(
sck,
keyfile=path.join(cert_path, "server-key.pem"),
certfile=path.join(cert_path, "server-cert.pem"),
keyfile=path.join(cert_path, "keycert.pem"),
certfile=path.join(cert_path, "keycert.pem"),
server_side=True,
ca_certs=path.join(cert_path, "ca-cert.pem"),
do_handshake_on_connect=False)
@ -76,7 +76,7 @@ def main():
try:
conn.do_handshake()
except SSLError as err:
if str(err).startswith("504:"):
if err.errno == 504:
continue
raise
print "Completed handshaking with peer"
@ -92,7 +92,7 @@ def main():
try:
message = conn.read()
except SSLError as err:
if str(err).startswith("502:"):
if err.errno == 502:
continue
if err.args[0] == SSL_ERROR_ZERO_RETURN:
break
@ -111,7 +111,7 @@ def main():
s = conn.shutdown()
s.shutdown(socket.SHUT_RDWR)
except SSLError as err:
if str(err).startswith("502:"):
if err.errno == 502:
continue
raise
break