Skip to content

Commit

Permalink
Merge pull request #15 from amaltaro/fix-13
Browse files Browse the repository at this point in the history
Set curl CAINFO variable to verify peer
  • Loading branch information
vkuznet authored Sep 16, 2024
2 parents 38000ca + ae23cfe commit 91b6e8a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/python/RestClient/AuthHandling/X509Auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from RestClient.ErrorHandling.RestClientExceptions import ClientAuthException

import os, sys
import certifi

class X509Auth(object):
def __init__(self, ca_path=None, ssl_cert=None, ssl_key=None, ssl_verifypeer=True, ca_info=None):
Expand All @@ -15,6 +16,9 @@ def __init__(self, ca_path=None, ssl_cert=None, ssl_key=None, ssl_verifypeer=Tru

if not self._ca_path:
self.__search_ca_path()
if not self._ca_info:
# then searches for the CA bundle to verify peer
self._ca_info = certifi.where()

#Check if ssl_cert, ssl_key and ca_path do exist
if not (os.path.isfile(self._ssl_key) and os.path.isfile(self._ssl_cert)):
Expand Down Expand Up @@ -89,9 +93,9 @@ def configure_auth(self, curl_object):
curl_object.setopt(curl_object.SSLCERT, self._ssl_cert)
curl_object.setopt(curl_object.SSLKEY, self._ssl_key)
if self._ca_info:
pass
# comment out as suggested. YG 2021-Oct-11
#curl_object.setopt(curl_object.CAINFO, self._ca_info)
curl_object.setopt(curl_object.CAINFO, self._ca_info)
else:
curl_object.setopt(curl_object.CAINFO, certifi.where())

if self.ssl_key_pass:
curl_object.setopt(curl_object.SSLKEYPASSWD, self.ssl_key_pass)
Expand Down

0 comments on commit 91b6e8a

Please sign in to comment.