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