TLSAbruptCloseError
I am using TLS Lite and J2ME SecureConnection for the purposes of encrypting traffic to/from a Java Midlet client and a multithreaded Python server. However, I encounter a TLSAbruptCloseError. I have tried to determine the cause of the exception to no avail. I understand that it has to do with close_notify alerts. My abbreviated code follows. // Server def sslSockRecv(conn, num): data = '' while len(data) < num: data = conn.recv(num - len(data)) # TLSAbruptCloseError thrown here if len(data) == 0: raise NotEnoughBytes ('Too few bytes from client. Expected ' + str(num) + '; got ' + str(len(data)), num, len(data)) return data sslSockRecv() throws NotEnoughBytes exception to indicate that the client has closed the connection. The NotEnoughBytes exception handler subsequently closes the SSL connection and then the underlying socket. // Client import javax.microedition.io.SecureConnection; sc = (SecureConnection)Connector.open("ssl://host:port"); inStream = sc.openInputStream(); outStream = sc.openOutputStream(); // read/write some data using streams if (inStream != null) inStream.close(); if (outStream != null) outStream.close(); if (sc != null) sc.close(); When using the Java phone emulator, SSLDump indicates after the application data portions. 3 13 0.3227 (0.0479) C>SV3.0(22) Alert level warning value close_notify 3 0.3228 (0.0000) C>S TCP FIN 3 14 0.3233 (0.0005) S>CV3.0(22) Alert level warning value close_notify However, the server doesn't throw a TLSAbruptCloseError when using the emulator. Using the actual phone does cause a TLSAbruptCloseError on the server but SSLDump reports no errors, just. 4 1.6258 (0.7012) C>S TCP FIN 4 1.6266 (0.0008) S>C TCP FIN Any thoughts? Todd Hopfinger
Any thoughts?
My main thought: this posting is off-topic for python-dev. This list is for the development of Python itself; use comp.lang.python for discussing development *with* Python. However, this may still be the wrong place - perhaps you better ask in a Java forum? Regards, Martin
On Tue, Jun 05, 2007 at 12:55:07PM -0400, Todd Hopfinger wrote:
I am using TLS Lite and J2ME SecureConnection for the purposes of encrypting traffic to/from a Java Midlet client and a multithreaded Python server. However, I encounter a TLSAbruptCloseError. I have tried to determine the cause of the exception to no avail. I understand that it has to do with close_notify alerts. My abbreviated code follows.
It may or may not be your specific problem, but Microsoft SSL servers tend to just drop the TCP connection when they're done, rather than do a proper SSL shutdown. This tends to make errors such as the above, which you must then ignore.
participants (3)
-
"Martin v. Löwis"
-
Jon Ribbens
-
Todd Hopfinger