Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for SSL Client Authentication #267

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 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,13 @@ 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)
opener = urllib.request.build_opener(handler)
urllib.request.install_opener(opener)

def _prepare_url_headers_and_body(self, query):
querystr = json.dumps(query.query_dict).encode("utf-8")
if self.url.endswith("/"):
Expand Down
2 changes: 1 addition & 1 deletion pydruid/db/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ def __init__(
context=None,
header=False,
ssl_verify_cert=True,
proxies=None,
ssl_client_cert=None,
proxies=None,
):
self.url = url
self.context = context or {}
Expand Down