Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0aee722

Browse files
committed
Hoepeful fix for SF bug #123924: Windows - using OpenSSL, problem with
socket in httplib.py. The bug reports that on Windows, you must pass sock._sock to the socket.ssl() call. But on Unix, you must pass sock itself. (sock is a wrapper on Windows but not on Unix; the ssl() call wants the real socket object, not the wrapper.) So we see if sock has an _sock attribute and if so, extract it. Unfortunately, the submitter of the bug didn't confirm that this patch works, so I'll just have to believe it (can't test it myself since I don't have OpenSSL on Windows set up, and that's a nontrivial thing I believe).
1 parent 0705028 commit 0aee722

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Lib/httplib.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,10 @@ def connect(self):
613613

614614
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
615615
sock.connect((self.host, self.port))
616-
ssl = socket.ssl(sock, self.key_file, self.cert_file)
616+
realsock = sock
617+
if hasattr(sock, "_sock"):
618+
realsock = sock._sock
619+
ssl = socket.ssl(realsock, self.key_file, self.cert_file)
617620
self.sock = FakeSocket(sock, ssl)
618621

619622

0 commit comments

Comments
 (0)