[Python-Dev] TLSAbruptCloseError

Todd Hopfinger thopfin at umich.edu
Tue Jun 5 18:55:07 CEST 2007


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-dev/attachments/20070605/3d14619b/attachment.htm 


More information about the Python-Dev mailing list