Skip to content

Commit

Permalink
Add support for custom CA certificates
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollins-ttd committed Jun 21, 2024
1 parent 8f46336 commit e8fff49
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion uid2_client/request_response_util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import base64
import os
import ssl
from urllib import request

import pkg_resources
Expand Down Expand Up @@ -43,4 +44,7 @@ def parse_v2_response(secret_key, encrypted, nonce):

def post(base_url, path, headers, data):
req = request.Request(_make_url(base_url, path), headers=headers, method='POST', data=data)
return request.urlopen(req)
uid2_ca_file = os.environ.get('UID2_CA_FILE')
uid2_ca_path = os.environ.get('UID2_CA_PATH')
uid2_ca_data = os.environ.get('UID2_CA_DATA')
return request.urlopen(req, context=ssl.create_default_context(cafile=uid2_ca_file, capath=uid2_ca_path, cadata=uid2_ca_data))

0 comments on commit e8fff49

Please sign in to comment.