From eba905f2b3421ba0090cf107aa975763888f3405 Mon Sep 17 00:00:00 2001 From: Alex Pilon Date: Fri, 9 Jul 2021 14:30:43 -0400 Subject: [PATCH] Add support for ssl client authentication --- pydruid/client.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pydruid/client.py b/pydruid/client.py index ae51eab7..d10bd550 100755 --- a/pydruid/client.py +++ b/pydruid/client.py @@ -15,6 +15,7 @@ # import json import re +import ssl import urllib from base64 import b64encode @@ -43,6 +44,12 @@ def set_proxies(self, proxies): opener = urllib.request.build_opener(proxy_support) urllib.request.install_opener(opener) + def set_cert_chain(self, certfile, keyfile=None, password=None): + context = ssl.create_default_context() + context.load_cert_chain(certfile, keyfile, password) + handler = urllib.request.HTTPSHandler(context=context) + urllib.request.install_opener(handler) + def _prepare_url_headers_and_body(self, query): querystr = json.dumps(query.query_dict).encode("utf-8") if self.url.endswith("/"):