From: Martin <md...@md...> - 2002-10-06 10:46:34
|
s=C3=B6n 2002-10-06 klockan 12.20 skrev Zoltan Felleg: > hello list, >=20 > i have a problem with pyOpenSSL, namely as follows: > i have created a client/server application, where the clients=20 > communicate with the servers on a secure channel. When a client tries to=20 > log in to a server (ie. after the SSL handshake it tries to send a=20 > message), the client dies with the subject, and the server gets a=20 > "connection reset by peer" exception. i have two questions about this: > a.) has anyone seen this before? > b.) is there an "official" way of handling the WantXYZError exceptions=20 > besides ignoring them? The WantXYZ exceptions are tricky, but that's because it's tricky in OpenSSL! If you get WantReadError that means OpenSSL wants to read from the socket but couldn't, so after you've made sure that the socket is readable, you should call *the same method* again, with *the same arguments*. It's symmetrical for WantWriteError. So, if for example you get a WantReadError when you do ssl.write('foo') you have to wait (using e.g. select) until the socket corresponding to `ssl' is readable, and then call ssl.write('foo') again. Yes, you can get WantReadErrors on writing, and WantWriteErrors on reading, since OpenSSL does handshakes transparently. > ps: both the client and server are multithreaded, the SSL connection is=20 > nonblocking, and the pyOpenSSL version is 0.5.1 If you're running multithreaded, you'd do well to use OpenSSL.tsafe.Connection instead of OpenSSL.SSL.Connection (tsafe stands for thread safe :)) Regards, Martin |