aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libpathod/pathod.py11
-rw-r--r--test/test_pathoc.py5
2 files changed, 11 insertions, 5 deletions
diff --git a/libpathod/pathod.py b/libpathod/pathod.py
index 4d8a0203..34afaa5a 100644
--- a/libpathod/pathod.py
+++ b/libpathod/pathod.py
@@ -9,10 +9,11 @@ class PathodError(Exception): pass
class SSLOptions:
- def __init__(self, certfile=None, keyfile=None, not_after_connect=None):
+ def __init__(self, certfile=None, keyfile=None, not_after_connect=None, request_client_cert=False):
self.keyfile = keyfile or utils.data.path("resources/server.key")
self.certfile = certfile or utils.data.path("resources/server.crt")
self.not_after_connect = not_after_connect
+ self.request_client_cert = request_client_cert
class PathodHandler(tcp.BaseHandler):
@@ -76,7 +77,8 @@ class PathodHandler(tcp.BaseHandler):
self.convert_to_ssl(
self.server.ssloptions.certfile,
self.server.ssloptions.keyfile,
- handle_sni = self.handle_sni
+ handle_sni = self.handle_sni,
+ request_client_cert = self.server.ssloptions.request_client_cert
)
except tcp.NetLibError, v:
s = str(v)
@@ -181,7 +183,8 @@ class PathodHandler(tcp.BaseHandler):
self.convert_to_ssl(
self.server.ssloptions.certfile,
self.server.ssloptions.keyfile,
- handle_sni = self.handle_sni
+ handle_sni = self.handle_sni,
+ request_client_cert = self.server.ssloptions.request_client_cert
)
except tcp.NetLibError, v:
s = str(v)
@@ -222,7 +225,7 @@ class Pathod(tcp.TCPServer):
"""
addr: (address, port) tuple. If port is 0, a free port will be
automatically chosen.
- ssloptions: a dictionary containing certfile and keyfile specifications.
+ ssloptions: an SSLOptions object.
craftanchor: string specifying the path under which to anchor response generation.
staticdir: path to a directory of static resources, or None.
anchors: A list of (regex, spec) tuples, or None.
diff --git a/test/test_pathoc.py b/test/test_pathoc.py
index 5391167f..31d73111 100644
--- a/test/test_pathoc.py
+++ b/test/test_pathoc.py
@@ -1,5 +1,5 @@
import json, cStringIO
-from libpathod import pathoc, test, version
+from libpathod import pathoc, test, version, pathod
import tutils
def test_response():
@@ -8,10 +8,12 @@ def test_response():
class _TestDaemon:
+ ssloptions = pathod.SSLOptions()
@classmethod
def setUpAll(self):
self.d = test.Daemon(
ssl=self.ssl,
+ ssloptions=self.ssloptions,
staticdir=tutils.test_data.path("data"),
anchors=[("/anchor/.*", "202")]
)
@@ -36,6 +38,7 @@ class _TestDaemon:
class TestDaemonSSL(_TestDaemon):
ssl = True
+ ssloptions = pathod.SSLOptions(request_client_cert=True)
def test_sni(self):
c = pathoc.Pathoc(
"127.0.0.1",