Skip to content

Commit a1119a8

Browse files
committed
Merge pull request ask#56 from ask/a38377d16358054af704e04cb90332875965070e
Require httplib2 0.7 (which added SSL cert verification) and trust DigiCert (only) which is used by Github.
2 parents b6c7efc + a38377d commit a1119a8

8 files changed

Lines changed: 37 additions & 22 deletions

File tree

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ include doc/Makefile
1111
include doc/.templates/layout.html
1212
prune doc/.build
1313

14+
include github2/*.crt
15+
1416
include tests/*.py
1517
recursive-include tests/data *

doc/api/client.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ API calls are limited by github.com to 1 per second by default. To have the
4242
>>> github = Github(username="ask", api_token=".......",
4343
... requests_per_second=1)
4444

45-
If you wish to use the library with a HTTP proxy, you will require a Python
46-
SOCKS module installed. :pypi:`SocksiPy-branch` is the module we test with, but
47-
various forks are available. Pass in the ``proxy_host`` and optionally
45+
If you wish to use a HTTP proxy you can pass in the ``proxy_host`` and
4846
``proxy_port`` settings to enable it. The default for ``proxy_port``, if not
4947
given, is 8080::
5048

doc/install.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ for handling HTTP sessions. :pypi:`python-dateutil` is used for its date
2525
handling [#]_. :pypi:`simplejson` is also required when using :mod:`github2`
2626
with Python 2.4 or 2.5. If you install via :pypi:`pip` or :pypi:`easy_install
2727
<setuptools>` the dependencies should be installed automatically for you.
28-
:pypi:`SocksiPy-branch` is an optional dependency if proxy support is needed.
2928

3029
.. [#] You must use :pypi:`python-dateutil` 1.x when working with Python 2.x,
3130
the latest 2.x releases are for Python 3.x installations only.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQU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N82oNLFpmyPInngiK3BD41VHMWEZ71jF
19+
hS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkKmNEVX58Svnw2
20+
Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe
21+
vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep
22+
+OkuE6N36B9K
23+
-----END CERTIFICATE-----

github2/request.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
import json as simplejson # For Python 2.6
88
except ImportError:
99
import simplejson
10-
try:
11-
import socks # SOCKS support may not be installed
12-
except ImportError:
13-
socks = None
10+
from os import path
1411
from urlparse import (urlsplit, urlunsplit)
1512
try:
1613
from urlparse import parse_qs
@@ -73,15 +70,15 @@ def __init__(self, username=None, api_token=None, url_prefix=None,
7370
"api_version": self.api_version,
7471
"api_format": self.api_format,
7572
}
73+
digicert_ha_cert = path.join(path.dirname(path.abspath(__file__ )),
74+
"DigiCert_High_Assurance_EV_Root_CA.crt")
7675
if proxy_host is None:
77-
self._http = httplib2.Http(cache=cache)
78-
elif proxy_host and socks is None:
79-
raise GithubError('Proxy support missing. '
80-
'Install a Python SOCKS library.')
76+
self._http = httplib2.Http(cache=cache, ca_certs=digicert_ha_cert)
8177
else:
82-
proxy_info = httplib2.ProxyInfo(socks.PROXY_TYPE_HTTP,
78+
proxy_info = httplib2.ProxyInfo(httplib2.socks.PROXY_TYPE_HTTP,
8379
proxy_host, proxy_port)
84-
self._http = httplib2.Http(proxy_info=proxy_info, cache=cache)
80+
self._http = httplib2.Http(proxy_info=proxy_info, cache=cache,
81+
ca_certs=digicert_ha_cert)
8582

8683
def encode_authentication_data(self, extra_post_data):
8784
if self.access_token:

setup.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import github2
99

1010

11-
install_requires = ['httplib2', ]
11+
install_requires = ['httplib2 >= 0.7.0', ]
1212
# simplejson is included in the standard library since Python 2.6 as json.
1313
if sys.version_info[:2] < (2, 6):
1414
install_requires.append('simplejson >= 2.0.9')
@@ -35,6 +35,8 @@
3535
keywords="git github api",
3636
platforms=["any"],
3737
packages=find_packages(exclude=['tests']),
38+
include_package_data=True,
39+
package_data={'': ['*.crt', ], },
3840
entry_points={
3941
'console_scripts': [
4042
'github_manage_collaborators = github2.bin.manage_collaborators:main',
@@ -45,9 +47,6 @@
4547
zip_safe=True,
4648
test_suite="nose.collector",
4749
tests_require=['nose'],
48-
extras_require={
49-
'SOCKS': ['SocksiPy-branch==1.01'],
50-
},
5150
classifiers=[
5251
"Development Status :: 5 - Production/Stable",
5352
"Intended Audience :: Developers",

tests/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class HttpMock(object):
2727
Implementation tests should never span network boundaries
2828
"""
2929

30-
def __init__(self, cache=None, timeout=None, proxy_info=None):
30+
def __init__(self, cache=None, timeout=None, proxy_info=None, ca_certs=None):
3131
"""Create a mock httplib.Http object
3232
3333
.. attribute: called_with

tox.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ envlist = py24, py25, py26, py27, py31, py32, rst, sphinx
66
deps =
77
nose
88
coverage
9-
10-
# Optional dep, but required for tests
11-
SocksiPy-branch
129
commands =
1310
rm -rf build
1411
{envpython} setup.py build

0 commit comments

Comments
 (0)