mercurial/debugcommands.py
changeset 33553 9c4e2aa0a239
parent 33507 e9672de52a23
child 34025 626a28f30dbd
child 34027 3c3066367d72
equal deleted inserted replaced
33552:754569f5e999 33553:9c4e2aa0a239
  2072 
  2072 
  2073     If the update succeeds, retry the original operation.  Otherwise, the cause
  2073     If the update succeeds, retry the original operation.  Otherwise, the cause
  2074     of the SSL error is likely another issue.
  2074     of the SSL error is likely another issue.
  2075     '''
  2075     '''
  2076     if pycompat.osname != 'nt':
  2076     if pycompat.osname != 'nt':
  2077         raise error.Abort(_('Certificate chain building is only possible on '
  2077         raise error.Abort(_('certificate chain building is only possible on '
  2078                             'Windows'))
  2078                             'Windows'))
  2079 
  2079 
  2080     if not source:
  2080     if not source:
  2081         source = "default"
  2081         source = "default"
  2082     elif not repo:
  2082     elif not repo:
  2090     if url.scheme == 'https':
  2090     if url.scheme == 'https':
  2091         addr = (url.host, url.port or 443)
  2091         addr = (url.host, url.port or 443)
  2092     elif url.scheme == 'ssh':
  2092     elif url.scheme == 'ssh':
  2093         addr = (url.host, url.port or 22)
  2093         addr = (url.host, url.port or 22)
  2094     else:
  2094     else:
  2095         raise error.Abort(_("Only https and ssh connections are supported"))
  2095         raise error.Abort(_("only https and ssh connections are supported"))
  2096 
  2096 
  2097     from . import win32
  2097     from . import win32
  2098 
  2098 
  2099     s = ssl.wrap_socket(socket.socket(), ssl_version=ssl.PROTOCOL_TLS,
  2099     s = ssl.wrap_socket(socket.socket(), ssl_version=ssl.PROTOCOL_TLS,
  2100                         cert_reqs=ssl.CERT_NONE, ca_certs=None)
  2100                         cert_reqs=ssl.CERT_NONE, ca_certs=None)
  2101 
  2101 
  2102     try:
  2102     try:
  2103         s.connect(addr)
  2103         s.connect(addr)
  2104         cert = s.getpeercert(True)
  2104         cert = s.getpeercert(True)
  2105 
  2105 
  2106         ui.status(_('Checking the certificate chain for %s.\n') % url.host)
  2106         ui.status(_('checking the certificate chain for %s\n') % url.host)
  2107 
  2107 
  2108         complete = win32.checkcertificatechain(cert, build=False)
  2108         complete = win32.checkcertificatechain(cert, build=False)
  2109 
  2109 
  2110         if not complete:
  2110         if not complete:
  2111             ui.status(_('The certificate chain is incomplete.  Updating... '))
  2111             ui.status(_('certificate chain is incomplete, updating... '))
  2112 
  2112 
  2113             if not win32.checkcertificatechain(cert):
  2113             if not win32.checkcertificatechain(cert):
  2114                 ui.status(_('Failed.\n'))
  2114                 ui.status(_('failed.\n'))
  2115             else:
  2115             else:
  2116                 ui.status(_('Done.\n'))
  2116                 ui.status(_('done.\n'))
  2117         else:
  2117         else:
  2118             ui.status(_('The full certificate chain is available.\n'))
  2118             ui.status(_('full certificate chain is available\n'))
  2119     finally:
  2119     finally:
  2120         s.close()
  2120         s.close()
  2121 
  2121 
  2122 @command('debugsub',
  2122 @command('debugsub',
  2123     [('r', 'rev', '',
  2123     [('r', 'rev', '',