aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--netlib/certutils.py9
-rw-r--r--test/test_certutils.py10
2 files changed, 9 insertions, 10 deletions
diff --git a/netlib/certutils.py b/netlib/certutils.py
index 94294f6e..0b29d52f 100644
--- a/netlib/certutils.py
+++ b/netlib/certutils.py
@@ -113,10 +113,11 @@ class CertStore:
"""
Implements an in-memory certificate store.
"""
- def __init__(self):
+ def __init__(self, cacert):
self.certs = {}
+ self.cacert = cacert
- def get_cert(self, commonname, sans, cacert):
+ def get_cert(self, commonname, sans):
"""
Returns an SSLCert object.
@@ -125,13 +126,11 @@ class CertStore:
sans: A list of Subject Alternate Names.
- cacert: The path to a CA certificate.
-
Return None if the certificate could not be found or generated.
"""
if commonname in self.certs:
return self.certs[commonname]
- c = dummy_cert(cacert, commonname, sans)
+ c = dummy_cert(self.cacert, commonname, sans)
self.certs[commonname] = c
return c
diff --git a/test/test_certutils.py b/test/test_certutils.py
index 7a00caca..4fab69e6 100644
--- a/test/test_certutils.py
+++ b/test/test_certutils.py
@@ -21,16 +21,16 @@ class TestCertStore:
with tutils.tmpdir() as d:
ca = os.path.join(d, "ca")
assert certutils.dummy_ca(ca)
- c = certutils.CertStore()
+ c = certutils.CertStore(ca)
def test_create_tmp(self):
with tutils.tmpdir() as d:
ca = os.path.join(d, "ca")
assert certutils.dummy_ca(ca)
- c = certutils.CertStore()
- assert c.get_cert("foo.com", [], ca)
- assert c.get_cert("foo.com", [], ca)
- assert c.get_cert("*.foo.com", [], ca)
+ c = certutils.CertStore(ca)
+ assert c.get_cert("foo.com", [])
+ assert c.get_cert("foo.com", [])
+ assert c.get_cert("*.foo.com", [])
class TestDummyCert: