From 1c7bdcad16246227a5c9b5ce4cc609fcc6ea3795 Mon Sep 17 00:00:00 2001 From: mcfreis Date: Fri, 17 Mar 2017 15:31:59 +0100 Subject: [PATCH] SSLError(): use errno with int-comparison instead of str().startswith()-comparison --- dtls/test/echo_seq.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dtls/test/echo_seq.py b/dtls/test/echo_seq.py index 52e4bce..87192e6 100644 --- a/dtls/test/echo_seq.py +++ b/dtls/test/echo_seq.py @@ -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