Show More
@@ -197,7 +197,7 b' def _hostsettings(ui, hostname):' | |||||
197 | cafile) |
|
197 | cafile) | |
198 | else: |
|
198 | else: | |
199 | # CAs not defined in config. Try to find system bundles. |
|
199 | # CAs not defined in config. Try to find system bundles. | |
200 | cafile = _defaultcacerts() |
|
200 | cafile = _defaultcacerts(ui) | |
201 | if cafile: |
|
201 | if cafile: | |
202 | ui.debug('using %s for CA file\n' % cafile) |
|
202 | ui.debug('using %s for CA file\n' % cafile) | |
203 |
|
203 | |||
@@ -430,7 +430,7 b' def _plainapplepython():' | |||||
430 | return (exe.startswith('/usr/bin/python') or |
|
430 | return (exe.startswith('/usr/bin/python') or | |
431 | exe.startswith('/system/library/frameworks/python.framework/')) |
|
431 | exe.startswith('/system/library/frameworks/python.framework/')) | |
432 |
|
432 | |||
433 | def _defaultcacerts(): |
|
433 | def _defaultcacerts(ui): | |
434 | """return path to default CA certificates or None.""" |
|
434 | """return path to default CA certificates or None.""" | |
435 | if _plainapplepython(): |
|
435 | if _plainapplepython(): | |
436 | dummycert = os.path.join(os.path.dirname(__file__), 'dummycert.pem') |
|
436 | dummycert = os.path.join(os.path.dirname(__file__), 'dummycert.pem') |
@@ -415,20 +415,22 b' def has_sslcontext():' | |||||
415 |
|
415 | |||
416 | @check("defaultcacerts", "can verify SSL certs by system's CA certs store") |
|
416 | @check("defaultcacerts", "can verify SSL certs by system's CA certs store") | |
417 | def has_defaultcacerts(): |
|
417 | def has_defaultcacerts(): | |
418 | from mercurial import sslutil |
|
418 | from mercurial import sslutil, ui as uimod | |
419 | return sslutil._defaultcacerts() or sslutil._canloaddefaultcerts |
|
419 | ui = uimod.ui() | |
|
420 | return sslutil._defaultcacerts(ui) or sslutil._canloaddefaultcerts | |||
420 |
|
421 | |||
421 | @check("defaultcacertsloaded", "detected presence of loaded system CA certs") |
|
422 | @check("defaultcacertsloaded", "detected presence of loaded system CA certs") | |
422 | def has_defaultcacertsloaded(): |
|
423 | def has_defaultcacertsloaded(): | |
423 | import ssl |
|
424 | import ssl | |
424 | from mercurial import sslutil |
|
425 | from mercurial import sslutil, ui as uimod | |
425 |
|
426 | |||
426 | if not has_defaultcacerts(): |
|
427 | if not has_defaultcacerts(): | |
427 | return False |
|
428 | return False | |
428 | if not has_sslcontext(): |
|
429 | if not has_sslcontext(): | |
429 | return False |
|
430 | return False | |
430 |
|
431 | |||
431 | cafile = sslutil._defaultcacerts() |
|
432 | ui = uimod.ui() | |
|
433 | cafile = sslutil._defaultcacerts(ui) | |||
432 | ctx = ssl.create_default_context() |
|
434 | ctx = ssl.create_default_context() | |
433 | if cafile: |
|
435 | if cafile: | |
434 | ctx.load_verify_locations(cafile=cafile) |
|
436 | ctx.load_verify_locations(cafile=cafile) |
General Comments 0
You need to be logged in to leave comments.
Login now