aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.mkd6
-rw-r--r--netlib/certutils.py3
-rw-r--r--netlib/odict.py3
-rw-r--r--setup.py1
-rw-r--r--test/test_certutils.py15
5 files changed, 24 insertions, 4 deletions
diff --git a/README.mkd b/README.mkd
index f0a26dd5..7c96d396 100644
--- a/README.mkd
+++ b/README.mkd
@@ -6,3 +6,9 @@ respects, because both pathod and mitmproxy often need to violate standards.
This means that protocols are implemented as small, well-contained and flexible
functions, and are designed to allow misbehaviour when needed.
+
+Requirements
+------------
+
+* [Python](http://www.python.org) 2.7.x.
+* Third-party packages listed in [setup.py](https://github.com/mitmproxy/netlib/blob/master/setup.py) \ No newline at end of file
diff --git a/netlib/certutils.py b/netlib/certutils.py
index 18179917..84316882 100644
--- a/netlib/certutils.py
+++ b/netlib/certutils.py
@@ -285,6 +285,9 @@ class SSLCert:
def __eq__(self, other):
return self.digest("sha1") == other.digest("sha1")
+ def __ne__(self, other):
+ return not self.__eq__(other)
+
@classmethod
def from_pem(klass, txt):
x509 = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, txt)
diff --git a/netlib/odict.py b/netlib/odict.py
index a0e1f694..1e51bb3f 100644
--- a/netlib/odict.py
+++ b/netlib/odict.py
@@ -24,6 +24,9 @@ class ODict:
def __eq__(self, other):
return self.lst == other.lst
+ def __ne__(self, other):
+ return not self.__eq__(other)
+
def __iter__(self):
return self.lst.__iter__()
diff --git a/setup.py b/setup.py
index 2dcfa248..80582772 100644
--- a/setup.py
+++ b/setup.py
@@ -82,6 +82,7 @@ setup(
"Development Status :: 3 - Alpha",
"Operating System :: POSIX",
"Programming Language :: Python",
+ "Programming Language :: Python :: 2",
"Topic :: Internet",
"Topic :: Internet :: WWW/HTTP :: HTTP Servers",
"Topic :: Software Development :: Testing",
diff --git a/test/test_certutils.py b/test/test_certutils.py
index 95a7280e..55fcc1dc 100644
--- a/test/test_certutils.py
+++ b/test/test_certutils.py
@@ -116,11 +116,15 @@ class TestDummyCert:
class TestSSLCert:
def test_simple(self):
- c = certutils.SSLCert.from_pem(file(tutils.test_data.path("data/text_cert"), "rb").read())
+ with open(tutils.test_data.path("data/text_cert"), "rb") as f:
+ d = f.read()
+ c = certutils.SSLCert.from_pem(d)
assert c.cn == "google.com"
assert len(c.altnames) == 436
- c = certutils.SSLCert.from_pem(file(tutils.test_data.path("data/text_cert_2"), "rb").read())
+ with open(tutils.test_data.path("data/text_cert_2"), "rb") as f:
+ d = f.read()
+ c = certutils.SSLCert.from_pem(d)
assert c.cn == "www.inode.co.nz"
assert len(c.altnames) == 2
assert c.digest("sha1")
@@ -134,12 +138,15 @@ class TestSSLCert:
c.has_expired
def test_err_broken_sans(self):
- c = certutils.SSLCert.from_pem(file(tutils.test_data.path("data/text_cert_weird1"), "rb").read())
+ with open(tutils.test_data.path("data/text_cert_weird1"), "rb") as f:
+ d = f.read()
+ c = certutils.SSLCert.from_pem(d)
# This breaks unless we ignore a decoding error.
c.altnames
def test_der(self):
- d = file(tutils.test_data.path("data/dercert"),"rb").read()
+ with open(tutils.test_data.path("data/dercert"), "rb") as f:
+ d = f.read()
s = certutils.SSLCert.from_der(d)
assert s.cn