M2Crypto: select() behaves weird on SSL sockets

Donn Cave donn at u.washington.edu
Mon Jun 10 14:59:07 EDT 2002


Quoth Irmen de Jong <irmen at NOSPAMREMOVETHISxs4all.nl>:

| I'm using m2crypto 0.07 snapshot 3 with Python 2.2.1
| and I'm experiencing weird behavior when using select().
|
| Basically, it seems that a SSL socket is no longer in ready
| state when entering select() again, after reading *a part*
| of the available data on the socket.
|
| Using plain sockets, the select() will keep reporting that
| the socket is ready for reading, until all data has been read.
| With SSL sockets, the second select() blocks eternally...
|
| Any clue? I really need the regular select() behavior,
| also on SSL sockets...

I'm no expert on this, but my theory is that you must call
SSL_pending(self->ssl) to see if any data remains in its buffer.
Then only when no data remains, you would call select.

I don't know if SSL guarantees it will work.  If the data in
the buffer is incomplete for SSL cryptography, then you might
not be able to exhaust it without causing a recv().  I hope
SSL_pending() returns 0 when no more decrypted data can be read,
but I don't have any documentation at all.

I don't think the socket module supports SSL_pending(), so
it would be up to you to put that in.

	Donn Cave, University Computing Services, University of Washington
	donn at u.washington.edu



More information about the Python-list mailing list