From 438f391a1a2fac8a0aec3f6f25bbf4305232aac6 Mon Sep 17 00:00:00 2001 From: Ben Murray Date: Thu, 21 Nov 2013 12:05:44 -0500 Subject: Fixes #3 Add HTTPS proxy support (if using the Python helper script) --- https_wrapper.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'https_wrapper.py') diff --git a/https_wrapper.py b/https_wrapper.py index c3a9ce3..94c0c8a 100644 --- a/https_wrapper.py +++ b/https_wrapper.py @@ -1,8 +1,6 @@ -#!/usr/bin/env python -# -# Adapted from: -# https://googleappengine.googlecode.com/svn-history/r136/trunk/python/google/appengine/tools/https_wrapper.py -# +### The following code was adapted from: +### https://googleappengine.googlecode.com/svn-history/r136/trunk/python/google/appengine/tools/https_wrapper.py + # Copyright 2007 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -49,6 +47,7 @@ class InvalidCertificateException(httplib.HTTPException): 'http://code.google.com/appengine/kb/general.html#rpcssl' % (self.host, self.reason, self.cert)) + class CertValidatingHTTPSConnection(httplib.HTTPConnection): """An HTTPConnection that connects over SSL and validates certificates.""" @@ -109,9 +108,11 @@ class CertValidatingHTTPSConnection(httplib.HTTPConnection): def connect(self): "Connect to a host on a given (SSL) port." - sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - sock.connect((self.host, self.port)) - self.sock = ssl.wrap_socket(sock, keyfile=self.key_file, + self.sock = socket.create_connection((self.host, self.port), + self.timeout) + if self._tunnel_host: + self._tunnel() + self.sock = ssl.wrap_socket(self.sock, keyfile=self.key_file, certfile=self.cert_file, cert_reqs=self.cert_reqs, ca_certs=self.ca_certs) -- cgit v1.2.3