This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: httplib does not handle ssl end of file properly
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.6
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: janssen Nosy List: Richie, brett.cannon, christian.heimes, janssen, martin.panter, vila
Priority: high Keywords: patch

Created on 2007-10-01 00:50 by Richie, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
e janssen, 2007-10-28 13:10
Messages (7)
msg56203 - (view) Author: Richie Ward (Richie) Date: 2007-10-01 00:50
I was using httplib to power my xml rpc script.

I had problems when I wanted to use SSL and I got this error:
 File "/usr/lib/python2.5/", line 1109, in recv
socket.sslerror: (8, 'EOF occurred in violation of protocol')

I figured out this was because of poor error handling in python.

May I suggest this as a fix to this bug:
$ diff /usr/lib/python2.5/ /usr/lib/python2.5/
<         try:
<             return
<         except socket.sslerror:
<             return
>         return

Just a note. I am by no means a python expert, just good enough to get
my work done.
I use Ubuntu gutsy.
msg56208 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2007-10-01 18:33
Patch is inlined in the opening comment for the issue.
msg56879 - (view) Author: Bill Janssen (janssen) * (Python committer) Date: 2007-10-28 13:10
I have a slightly different version of this patch in the new SSL code.  
It (optionally, but defaulting to True) catches SSL_ERROR_EOF and returns 
None, but allows other ssl errors to go through.
msg58410 - (view) Author: Bill Janssen (janssen) * (Python committer) Date: 2007-12-11 03:13
I'll close this when the fix gets into all the branches (right now it's
in the pre-2.6 code, and in the 3K code, but not yet in the 2.6 branch).
msg61570 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2008-01-23 08:51
I've set version to 2.6 and priority to high so we don't forget it.
msg68979 - (view) Author: Bill Janssen (janssen) * (Python committer) Date: 2008-06-30 01:06
I believe this is now fixed in the SVN.

There's a new parameter on SSLSocket, suppress_ragged_eofs, which allows
it to be enabled selectively, but default to True.
msg273209 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-08-20 13:21
I think the default of suppress_ragged_eofs=True was a bad idea because by default you cannot tell a secure EOF signal from an insecure error; see Issue 27815.
Date User Action Args
2022-04-11 14:56:27adminsetgithub: 45564
2016-08-20 13:21:13martin.pantersetnosy: + martin.panter
messages: + msg273209
2008-12-05 09:43:30georg.brandlsetstatus: open -> closed
2008-09-04 01:20:43janssensetresolution: accepted -> fixed
2008-06-30 01:06:54janssensetresolution: accepted
messages: + msg68979
2008-01-23 08:51:25christian.heimessetpriority: high
nosy: + christian.heimes
messages: + msg61570
versions: + Python 2.6, - Python 2.5
2008-01-23 08:35:49gregory.p.smithsetassignee: janssen
2008-01-05 11:32:54vilasetnosy: + vila
2007-12-11 03:13:21janssensetmessages: + msg58410
2007-10-28 13:10:58janssensetfiles: + e
nosy: + janssen
messages: + msg56879
2007-10-01 18:33:18brett.cannonsetkeywords: + patch
type: crash -> behavior
messages: + msg56208
nosy: + brett.cannon
2007-10-01 00:51:12Richiesetversions: + Python 2.5, - Python 2.6
2007-10-01 00:50:09Richiecreate