Message7731

Author amak
Recipients amak, t-8ch
Date 2013-02-23.15:21:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1361632900.38.0.347550901323.issue2016@psf.upfronthosting.co.za>
In-reply-to
Content
Hmm, there seems to have been an implicit API change between cpython 2.5 socket.ssl and cpython 2.7 ssl module.

Cpython 2.5 ssl sockets, as returned from socket.ssl, do not have recv() (et al) methods.

C:\>C:\Python25\python.exe
Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> import time
>>> sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>> sock.connect( ('httpbin.org', 443) )
>>> ssl_sock = socket.ssl(sock)
>>> ssl_sock.write("GET /ip HTTP/1.1\r\nHost:httpbin.org\r\n\r\n")
38
>>> print(ssl_sock.recv(10000))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: recv
>>>

But SSLSockets, as returned from ssl.wrap_socket do have the method

X:\xhaus\jython\jython_25\dist>C:\Python27\python.exe
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> import socket
>>> import time
>>> sock = socket.create_connection(('httpbin.org', 443))
>>> ssl_sock = ssl.wrap_socket(sock)
>>> ssl_sock.write("GET /ip HTTP/1.1\r\nHost:httpbin.org\r\n\r\n")
38
>>> print(ssl_sock.recv(10000))
HTTP/1.1 200 OK
>>>

Even though the methods are undocumented, as can be seen on the module documentation page, where only the read and write methods are documented, not recv() et al.

http://docs.python.org/2.7/library/ssl.html#sslsocket-objects

I think I'm going to have to seek clarity from the cpython folks on this one. Either

A: The methods should be supported, in which case they should be documented or
B: The methods should not be supported

It is indeed the case that the current implementation delegates the recv() et al methods to the underlying socket, and should not, because they operate on the unwrapped/unencrypted socket. I will fix this straightaway. The immediate fix will be to not support the methods for now, until the cpython question of undocumented methods is resolved.
History
Date User Action Args
2013-02-23 15:21:40amaksetmessageid: <1361632900.38.0.347550901323.issue2016@psf.upfronthosting.co.za>
2013-02-23 15:21:40amaksetrecipients: + amak, t-8ch
2013-02-23 15:21:40amaklinkissue2016 messages
2013-02-23 15:21:39amakcreate