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

Set curl CAINFO variable to verify peer #15

Merged
merged 1 commit into from
Sep 16, 2024
Merged
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
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