##// END OF EJS Templates
sslutil: try to find CA certficates in well-known locations...
Gregory Szorc -
r29500:4b16a5bd default
parent child Browse files
Show More
@@ -430,12 +430,22 def _plainapplepython():
430 430 return (exe.startswith('/usr/bin/python') or
431 431 exe.startswith('/system/library/frameworks/python.framework/'))
432 432
433 _systemcacertpaths = [
434 # RHEL, CentOS, and Fedora
435 '/etc/pki/tls/certs/ca-bundle.trust.crt',
436 # Debian, Ubuntu, Gentoo
437 '/etc/ssl/certs/ca-certificates.crt',
438 ]
439
433 440 def _defaultcacerts(ui):
434 441 """return path to default CA certificates or None.
435 442
436 443 It is assumed this function is called when the returned certificates
437 444 file will actually be used to validate connections. Therefore this
438 445 function may print warnings or debug messages assuming this usage.
446
447 We don't print a message when the Python is able to load default
448 CA certs because this scenario is detected at socket connect time.
439 449 """
440 450 # The "certifi" Python package provides certificates. If it is installed,
441 451 # assume the user intends it to be used and use it.
@@ -480,6 +490,28 def _defaultcacerts(ui):
480 490 'how to configure Mercurial to avoid this message)\n'))
481 491 return None
482 492
493 # Try to find CA certificates in well-known locations. We print a warning
494 # when using a found file because we don't want too much silent magic
495 # for security settings. The expectation is that proper Mercurial
496 # installs will have the CA certs path defined at install time and the
497 # installer/packager will make an appropriate decision on the user's
498 # behalf. We only get here and perform this setting as a feature of
499 # last resort.
500 if not _canloaddefaultcerts:
501 for path in _systemcacertpaths:
502 if os.path.isfile(path):
503 ui.warn(_('(using CA certificates from %s; if you see this '
504 'message, your Mercurial install is not properly '
505 'configured; see '
506 'https://mercurial-scm.org/wiki/SecureConnections '
507 'for how to configure Mercurial to avoid this '
508 'message)\n') % path)
509 return path
510
511 ui.warn(_('(unable to load CA certificates; see '
512 'https://mercurial-scm.org/wiki/SecureConnections for '
513 'how to configure Mercurial to avoid this message)\n'))
514
483 515 return None
484 516
485 517 def validatesocket(sock):
@@ -56,6 +56,7 we are able to load CA certs.
56 56
57 57 #if no-sslcontext defaultcacerts
58 58 $ hg clone https://localhost:$HGPORT/ copy-pull
59 (using CA certificates from *; if you see this message, your Mercurial install is not properly configured; see https://mercurial-scm.org/wiki/SecureConnections for how to configure Mercurial to avoid this message) (glob) (?)
59 60 abort: error: *certificate verify failed* (glob)
60 61 [255]
61 62 #endif
@@ -77,6 +78,7 we are able to load CA certs.
77 78
78 79 #if defaultcacertsloaded
79 80 $ hg clone https://localhost:$HGPORT/ copy-pull
81 (using CA certificates from *; if you see this message, your Mercurial install is not properly configured; see https://mercurial-scm.org/wiki/SecureConnections for how to configure Mercurial to avoid this message) (glob) (?)
80 82 abort: error: *certificate verify failed* (glob)
81 83 [255]
82 84 #endif
@@ -58,6 +58,7 we are able to load CA certs:
58 58 this patch series consists of 1 patches.
59 59
60 60
61 (using CA certificates from *; if you see this message, your Mercurial install is not properly configured; see https://mercurial-scm.org/wiki/SecureConnections for how to configure Mercurial to avoid this message) (glob) (?)
61 62 (?i)abort: .*?certificate.verify.failed.* (re)
62 63 [255]
63 64 #endif
@@ -67,6 +68,7 we are able to load CA certs:
67 68 this patch series consists of 1 patches.
68 69
69 70
71 (using CA certificates from *; if you see this message, your Mercurial install is not properly configured; see https://mercurial-scm.org/wiki/SecureConnections for how to configure Mercurial to avoid this message) (glob) (?)
70 72 (?i)abort: .*?certificate.verify.failed.* (re)
71 73 [255]
72 74
General Comments 0
You need to be logged in to leave comments. Login now