Skip to content

Commit eba905f

Browse files
committed
Add support for ssl client authentication
1 parent 98cab4d commit eba905f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pydruid/client.py

+7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#
1616
import json
1717
import re
18+
import ssl
1819
import urllib
1920
from base64 import b64encode
2021

@@ -43,6 +44,12 @@ def set_proxies(self, proxies):
4344
opener = urllib.request.build_opener(proxy_support)
4445
urllib.request.install_opener(opener)
4546

47+
def set_cert_chain(self, certfile, keyfile=None, password=None):
48+
context = ssl.create_default_context()
49+
context.load_cert_chain(certfile, keyfile, password)
50+
handler = urllib.request.HTTPSHandler(context=context)
51+
urllib.request.install_opener(handler)
52+
4653
def _prepare_url_headers_and_body(self, query):
4754
querystr = json.dumps(query.query_dict).encode("utf-8")
4855
if self.url.endswith("/"):

0 commit comments

Comments
 (0)