Bug 642809

Summary: Traceback when attempting to serve content over SSL
Product: [Fedora] Fedora Reporter: Ryan McCabe <rmccabe>
Component: pyOpenSSLAssignee: Paul F. Johnson <paul>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: high    
Version: 14CC: a.badger, dmalcolm, fdinitto, fschwarz, ivazqueznet, james.antill, jonathansteffan, jpokorny, kylev, lmacken, paul, robinlee.sysu
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: pyOpenSSL-0.9-3.fc14 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-12-17 08:25:26 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Allow pyopenssl sendall to utilize a memoryview none

Description Ryan McCabe 2010-10-13 20:49:17 UTC
Description of problem:

I get this traceback when attempting to serve content over SSL:

----------------------------------------
Exception happened during processing of request from ('192.168.122.1', 45544)
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/paste/httpserver.py", line 1068, in process_request_in_thread
    self.finish_request(request, client_address)
  File "/usr/lib64/python2.7/SocketServer.py", line 323, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib64/python2.7/SocketServer.py", line 641, in __init__
    self.finish()
  File "/usr/lib64/python2.7/SocketServer.py", line 694, in finish
    self.wfile.flush()
  File "/usr/lib64/python2.7/socket.py", line 301, in flush
    self._sock.sendall(view[write_offset:write_offset+buffer_size])
TypeError: must be string or read-only buffer, not memoryview
----------------------------------------

If I comment out the ssl_pem config parameter, the content is served as expected.


Version-Release number of selected component (if applicable):

python-paste-1.7.4-7.fc14


Steps to Reproduce:

set the "ssl_pem" config parameter in the [server:main] section of the application's ini file.

Comment 1 Dave Malcolm 2010-10-14 18:03:16 UTC
FWIW, "memoryview" objects are new in Python 2.7:
  http://docs.python.org/library/stdtypes.html#memoryview-type

Comment 2 Dave Malcolm 2010-10-14 18:25:57 UTC
Modules/socketmodule.:sock_sendall calls:
    if (!PyArg_ParseTuple(args, "s*|i:sendall", &pbuf, &flags))
This is what's emitting the:
    TypeError: must be string or read-only buffer, not memoryview
message, within getargs.c:convertbuffer()

This looks similar to this upstream problem:
  http://bugs.python.org/issue7133
though the fix for that is in the Python-2.7.tar.bz2 tarball in F14.

Comment 3 Luke Macken 2010-10-18 17:40:22 UTC
Re-assigning to Python

Comment 4 Toshio Ernie Kuratomi 2010-12-07 23:38:47 UTC
Tracked this down.  It's an incompatibility between python-2.7's socket and pyOpenSSL.  (The relevant code isn't actually in Modules/socketmodule.c.  The self._sock that's getting used is from PyOpenSSL => OpenSSL.SSL.Connection

This build seems to work for me:
http://koji.fedoraproject.org/koji/taskinfo?taskID=2650286

I'll attach patch, reassign to pyOpenSSL and submit upstream.

Comment 5 Toshio Ernie Kuratomi 2010-12-07 23:41:53 UTC
Created attachment 467328 [details]
Allow pyopenssl sendall to utilize a memoryview

Allow pyopenssl sendall to utilize a memoryview

Comment 6 Toshio Ernie Kuratomi 2010-12-07 23:52:34 UTC
Paul, I've built new packages for F14 and rawhide.  If you don't object, I'll push the F14 one to stable after a suitable time in testing.  rmmcabe, when it comes out, please test the update to see if it works for you.

Comment 7 Fedora Update System 2010-12-08 01:03:00 UTC
pyOpenSSL-0.9-3.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/pyOpenSSL-0.9-3.fc14

Comment 8 Fedora Update System 2010-12-08 21:42:07 UTC
pyOpenSSL-0.9-3.fc14 has been pushed to the Fedora 14 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update pyOpenSSL'.  You can provide feedback for this update here: https://admin.fedoraproject.org/updates/pyOpenSSL-0.9-3.fc14

Comment 9 Fedora Update System 2010-12-17 08:25:20 UTC
pyOpenSSL-0.9-3.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.