Skip to content

Commit

Permalink
Add ssl certificate support
Browse files Browse the repository at this point in the history
  • Loading branch information
xaptronic committed Jul 9, 2021
1 parent 98cab4d commit b7c269a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pydruid/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#
import json
import re
import ssl
import urllib
from base64 import b64encode

Expand Down Expand Up @@ -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, cert, keyfile):
context = ssl.create_default_context()
context.load_cert_chain(cert, keyfile)
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("/"):
Expand Down

0 comments on commit b7c269a

Please sign in to comment.