diff --git a/libmproxy/proxy/config.py b/libmproxy/proxy/config.py index f06e55cab..b14786552 100644 --- a/libmproxy/proxy/config.py +++ b/libmproxy/proxy/config.py @@ -133,12 +133,9 @@ def process_proxy_options(parser, options): if options.clientcerts: options.clientcerts = os.path.expanduser(options.clientcerts) - if not (os.path.exists(options.clientcerts) or - os.path.isdir(options.clientcerts) or - os.path.isfile(options.clientcerts)): + if not os.path.exists(options.clientcerts): return parser.error( - "Client certificate argument is not a file or directory, " - "or does not exist: %s" % options.clientcerts + "Client certificate path does not exist: %s" % options.clientcerts ) if options.auth_nonanonymous or options.auth_singleuser or options.auth_htpasswd: diff --git a/test/test_proxy.py b/test/test_proxy.py index a0530c79d..b498c800b 100644 --- a/test/test_proxy.py +++ b/test/test_proxy.py @@ -104,7 +104,7 @@ class TestProcessProxyOptions: "--client-certs", os.path.join(tutils.test_data.path("data/clientcert"), "client.pem")) self.assert_err( - "not a file or directory", + "path does not exist", "--client-certs", "nonexistent") diff --git a/test/test_server.py b/test/test_server.py index 09cfa3815..85c766eb4 100644 --- a/test/test_server.py +++ b/test/test_server.py @@ -314,21 +314,24 @@ class TestHTTPAuth(tservers.HTTPProxTest): class TestHTTPS(tservers.HTTPProxTest, CommonMixin, TcpMixin): ssl = True ssloptions = pathod.SSLOptions(request_client_cert=True) - clientcerts = True - - def test_clientcert(self): - self.config.clientcerts = os.path.join( - tutils.test_data.path("data/clientcert"), "client.pem") - f = self.pathod("304") - assert f.status_code == 304 - assert self.server.last_log()["request"]["clientcert"]["keyinfo"] - - def test_clientcerts(self): - self.config.clientcerts = tutils.test_data.path("data/clientcert") - f = self.pathod("304") - assert f.status_code == 304 - assert self.server.last_log()["request"]["clientcert"]["keyinfo"] + def test_clientcert_file(self): + try: + self.config.clientcerts = os.path.join( + tutils.test_data.path("data/clientcert"), "client.pem") + f = self.pathod("304") + assert f.status_code == 304 + assert self.server.last_log()["request"]["clientcert"]["keyinfo"] + finally: + self.config.clientcerts = None + def test_clientcert_dir(self): + try: + self.config.clientcerts = tutils.test_data.path("data/clientcert") + f = self.pathod("304") + assert f.status_code == 304 + assert self.server.last_log()["request"]["clientcert"]["keyinfo"] + finally: + self.config.clientcerts = None def test_error_post_connect(self): p = self.pathoc() assert p.request("get:/:i0,'invalid\r\n\r\n'").status_code == 400 diff --git a/test/tservers.py b/test/tservers.py index 8e60df603..5963667b5 100644 --- a/test/tservers.py +++ b/test/tservers.py @@ -83,7 +83,6 @@ class ProxTestBase(object): # Test Configuration ssl = None ssloptions = False - clientcerts = False no_upstream_cert = False authenticator = None masterclass = TestMaster @@ -130,7 +129,6 @@ class ProxTestBase(object): no_upstream_cert = cls.no_upstream_cert, cadir = cls.cadir, authenticator = cls.authenticator, - clientcerts = tutils.test_data.path("data/clientcert") if cls.clientcerts else None )