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.

classification
Title: HTTPS and sending a big file size hangs.
Type: behavior Stage:
Components: Library (Lib), Windows Versions: Python 2.7
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: James.O'Cull, jesusvpct, pitrou
Priority: normal Keywords:

Created on 2013-05-10 07:43 by jesusvpct, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (7)
msg188816 - (view) Author: Jesús Vidal Panalés (jesusvpct) Date: 2013-05-10 07:43
This bug was found using Mercurial. All the information it's on this bug link http://bz.selenic.com/show_bug.cgi?id=3905

The bug was introduced on 2.7.3, previous versions works fine.
msg188819 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-05-10 09:07
Hello Jesus, this report is far too vague to make anything about it. You should try to diagnose the issue further, here are some ideas:
- check whether it happens with another server than IIS
- try if you can reproduce without Mercurial being involved (simply write a script using httplib or urllib2 to push a file to the server)
- try to see what happens over the wire using e.g. Wireshark

Bonus points if you can find an easy way to reproduce, short of hosting a large Mercurial repo on a Windows server :-)
msg188858 - (view) Author: James O'Cull (James.O'Cull) Date: 2013-05-10 18:11
We have more information on this bug here. It's SSL v2 related when pushing to IIS.

http://stackoverflow.com/a/16486104/97964

Here's a paste from the StackOverflow answer:

	I found a few ways of dealing with this issue:

	To fix this server-side in IIS, download and install https://www.nartac.com/Products/IISCrypto/Default.aspx and click the BEAST button, or force SSL3.0 by disabling other protocols.

	If you don't have access to the IIS server, you can fix it by rolling back Python to version 2.7.2 or earlier.

	If you are adventurous, you can modify the mercurial source in sslutil.py, near the top, change the line

	sslsocket = ssl.wrap_socket(sock, keyfile, certfile,
				cert_reqs=cert_reqs, ca_certs=ca_certs)

	to

	from _ssl import PROTOCOL_SSLv3
	sslsocket = ssl.wrap_socket(sock, keyfile, certfile,
				cert_reqs=cert_reqs, ca_certs=ca_certs, ssl_version=PROTOCOL_SSLv3)

	This will work around the problem and fix the push limit to mercurial behind IIS.

	If you are interested in why Python 2.7.3 broke this, look at http://bugs.python.org/issue13885 for the explanation (it is security-related). If you want to modify Python itself, in Modules/_ssl.c change the line

	SSL_CTX_set_options(self->ctx,
						SSL_OP_ALL & ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS);

	back to how it was prior to 2.7.3:

	SSL_CTX_set_options(self->ctx, SSL_OP_ALL);

	Compile and reinstall python, etc. This adds more SSL compatibility at the expense of potential security risks, if I understand the OpenSSL docs correctly.
msg188860 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-05-10 18:19
Thank you for pointing this out. I am frankly shocked that IIS would defaut to SSLv2 (an obsolete and insecure version of the protocol), while Python's (and certainly Mercurial's) default settings allow for higher protocol versions.

> If you are interested in why Python 2.7.3 broke this, look at
> http://bugs.python.org/issue13885 for the explanation (it is
> security-related).

Indeed, it is a security fix. I have no desire to undo this change, which means things may get a bit painful with IIS apparently.

One way to deal with it may be to detect IIS after the first wrap_socket() (through an HTTP header in the response?) and then re-issue a wrap_socket() with IIS-specific parameters.

(forcing SSLv3 as the client protocol isn't terrific, since TLSv1 is AFAIR supposed to have improved security)
msg188861 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-05-10 18:20
Closing as won't fix. I hope you'll find a reasonable to deal with this, sorry :-/
msg188862 - (view) Author: James O'Cull (James.O'Cull) Date: 2013-05-10 18:28
I appreciate the response all the same. Thanks for taking the time to look at it, Antoine.
msg188863 - (view) Author: Jesús Vidal Panalés (jesusvpct) Date: 2013-05-10 18:34
Thank you. I will modify IIS security to disable SSL older verions.
History
Date User Action Args
2022-04-11 14:57:45adminsetgithub: 62148
2013-05-10 18:34:44jesusvpctsetmessages: + msg188863
2013-05-10 18:28:19James.O'Cullsetmessages: + msg188862
2013-05-10 18:20:22pitrousetstatus: open -> closed
resolution: wont fix
messages: + msg188861
2013-05-10 18:19:44pitrousetmessages: + msg188860
2013-05-10 18:11:21James.O'Cullsetnosy: + James.O'Cull
messages: + msg188858
2013-05-10 09:07:43pitrousetnosy: + pitrou
messages: + msg188819
components: + Library (Lib)
2013-05-10 07:43:49jesusvpctcreate