Skip to content

Commit

Permalink
[_519][_281] force verify mode to CERT_NONE if irods verify setting i…
Browse files Browse the repository at this point in the history
…s explicitly none
  • Loading branch information
d-w-moore committed Mar 14, 2024
1 parent 30b05a6 commit 00e9cc2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions irods/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,14 @@ def requires_cs_negotiation(self):

@staticmethod
def make_ssl_context(irods_account):
check_hostname = getattr(irods_account,'ssl_verify_server','hostname')
verify_server = getattr(irods_account,'ssl_verify_server','hostname')
CAfile = getattr(irods_account,'ssl_ca_certificate_file',None)
CApath = getattr(irods_account,'ssl_ca_certificate_path',None)
verify = ssl.CERT_NONE if (None is CAfile is CApath) else ssl.CERT_REQUIRED
verify = ssl.CERT_NONE if ((None is CAfile is CApath) or verify_server == 'none') else ssl.CERT_REQUIRED
# See https://stackoverflow.com/questions/30461969/disable-default-certificate-verification-in-python-2-7-9/49040695#49040695
ctx = ssl.create_default_context(ssl.Purpose.SERVER_AUTH, cafile=CAfile, capath=CApath)
# Note: check_hostname must be assigned prior to verify_mode property or Python library complains!
ctx.check_hostname = (check_hostname.startswith('host') and verify != ssl.CERT_NONE)
ctx.check_hostname = (verify_server.startswith('host') and verify != ssl.CERT_NONE)
ctx.verify_mode = verify
return ctx

Expand Down

0 comments on commit 00e9cc2

Please sign in to comment.