def test_with_ca(self): with tutils.tmpdir() as d: cacert = os.path.join(d, "cacert") assert certutils.dummy_ca(cacert) p = os.path.join(d, "foo") certutils.dummy_cert(file(p, "w"), cacert, "foo.com", ["one.com", "two.com", "*.three.com"]) assert file(p).read()
def test_with_ca(self): with tutils.tmpdir() as d: ca = certutils.CertStore.from_store(d, "test") r = certutils.dummy_cert(ca.default_privatekey, ca.default_ca, b"foo.com", [b"one.com", b"two.com", b"*.three.com"]) assert r.cn == b"foo.com" r = certutils.dummy_cert(ca.default_privatekey, ca.default_ca, None, []) assert r.cn is None
def test_with_ca(self): with tutils.tmpdir() as d: cacert = os.path.join(d, "cacert") assert certutils.dummy_ca(cacert) p = os.path.join(d, "foo") certutils.dummy_cert( file(p, "w"), cacert, "foo.com", ["one.com", "two.com", "*.three.com"] ) assert file(p).read()
def test_with_ca(self): with tutils.tmpdir() as d: ca = certutils.CertStore.from_store(d, "test") r = certutils.dummy_cert( ca.default_privatekey, ca.default_ca, b"foo.com", [b"one.com", b"two.com", b"*.three.com"] ) assert r.cn == b"foo.com"
def test_no_ca(self): with tutils.tmpdir() as d: p = certutils.dummy_cert( d, None, "foo.com", [] ) assert os.path.exists(p)
def test_with_ca(self): with tutils.tmpdir() as d: cacert = os.path.join(d, "foo/cert.cnf") assert certutils.dummy_ca(cacert) p = certutils.dummy_cert( os.path.join(d, "foo"), cacert, "foo.com", ["one.com", "two.com", "*.three.com"] ) assert os.path.exists(p) # Short-circuit assert certutils.dummy_cert( os.path.join(d, "foo"), cacert, "foo.com", [] )
def test_with_ca(self): with tutils.tmpdir() as d: cacert = os.path.join(d, "cacert") assert certutils.dummy_ca(cacert) r = certutils.dummy_cert( cacert, "foo.com", ["one.com", "two.com", "*.three.com"] ) assert r.cn == "foo.com"
def test_with_ca(self): with tutils.tmpdir() as d: ca = certutils.CertStore.from_store(d, "test") r = certutils.dummy_cert( ca.privkey, ca.cacert, "foo.com", ["one.com", "two.com", "*.three.com"] ) assert r.cn == "foo.com"
def find_cert(self, host, port, sni): if self.config.certfile: return self.config.certfile else: sans = [] if self.config.upstream_cert: cert = certutils.get_remote_cert(host, port, sni) sans = cert.altnames host = cert.cn ret = certutils.dummy_cert(self.config.certdir, self.config.cacert, host, sans) time.sleep(self.config.cert_wait_time) if not ret: raise ProxyError(502, "mitmproxy: Unable to generate dummy cert.") return ret
def find_cert(self, host, port, sni): if self.config.certfile: return self.config.certfile else: sans = [] if not self.config.no_upstream_cert: try: cert = certutils.get_remote_cert(host, port, sni) except tcp.NetLibError, v: raise ProxyError(502, "Unable to get remote cert: %s"%str(v)) sans = cert.altnames host = cert.cn.decode("utf8").encode("idna") ret = certutils.dummy_cert(self.config.certdir, self.config.cacert, host, sans) time.sleep(self.config.cert_wait_time) if not ret: raise ProxyError(502, "mitmproxy: Unable to generate dummy cert.") return ret