##// END OF EJS Templates
ssl: only use the dummy cert hack if using an Apple Python (issue4410)...
Mads Kiilerich -
r23042:2cd3fa44 default
parent child Browse files
Show More
@@ -1,179 +1,193 b''
1 # sslutil.py - SSL handling for mercurial
1 # sslutil.py - SSL handling for mercurial
2 #
2 #
3 # Copyright 2005, 2006, 2007, 2008 Matt Mackall <mpm@selenic.com>
3 # Copyright 2005, 2006, 2007, 2008 Matt Mackall <mpm@selenic.com>
4 # Copyright 2006, 2007 Alexis S. L. Carvalho <alexis@cecm.usp.br>
4 # Copyright 2006, 2007 Alexis S. L. Carvalho <alexis@cecm.usp.br>
5 # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com>
5 # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com>
6 #
6 #
7 # This software may be used and distributed according to the terms of the
7 # This software may be used and distributed according to the terms of the
8 # GNU General Public License version 2 or any later version.
8 # GNU General Public License version 2 or any later version.
9 import os, sys
9 import os, sys
10
10
11 from mercurial import util
11 from mercurial import util
12 from mercurial.i18n import _
12 from mercurial.i18n import _
13 try:
13 try:
14 # avoid using deprecated/broken FakeSocket in python 2.6
14 # avoid using deprecated/broken FakeSocket in python 2.6
15 import ssl
15 import ssl
16 CERT_REQUIRED = ssl.CERT_REQUIRED
16 CERT_REQUIRED = ssl.CERT_REQUIRED
17 PROTOCOL_SSLv23 = ssl.PROTOCOL_SSLv23
17 PROTOCOL_SSLv23 = ssl.PROTOCOL_SSLv23
18 PROTOCOL_TLSv1 = ssl.PROTOCOL_TLSv1
18 PROTOCOL_TLSv1 = ssl.PROTOCOL_TLSv1
19 def ssl_wrap_socket(sock, keyfile, certfile, ssl_version=PROTOCOL_TLSv1,
19 def ssl_wrap_socket(sock, keyfile, certfile, ssl_version=PROTOCOL_TLSv1,
20 cert_reqs=ssl.CERT_NONE, ca_certs=None):
20 cert_reqs=ssl.CERT_NONE, ca_certs=None):
21 sslsocket = ssl.wrap_socket(sock, keyfile, certfile,
21 sslsocket = ssl.wrap_socket(sock, keyfile, certfile,
22 cert_reqs=cert_reqs, ca_certs=ca_certs,
22 cert_reqs=cert_reqs, ca_certs=ca_certs,
23 ssl_version=ssl_version)
23 ssl_version=ssl_version)
24 # check if wrap_socket failed silently because socket had been closed
24 # check if wrap_socket failed silently because socket had been closed
25 # - see http://bugs.python.org/issue13721
25 # - see http://bugs.python.org/issue13721
26 if not sslsocket.cipher():
26 if not sslsocket.cipher():
27 raise util.Abort(_('ssl connection failed'))
27 raise util.Abort(_('ssl connection failed'))
28 return sslsocket
28 return sslsocket
29 except ImportError:
29 except ImportError:
30 CERT_REQUIRED = 2
30 CERT_REQUIRED = 2
31
31
32 PROTOCOL_SSLv23 = 2
32 PROTOCOL_SSLv23 = 2
33 PROTOCOL_TLSv1 = 3
33 PROTOCOL_TLSv1 = 3
34
34
35 import socket, httplib
35 import socket, httplib
36
36
37 def ssl_wrap_socket(sock, keyfile, certfile, ssl_version=PROTOCOL_TLSv1,
37 def ssl_wrap_socket(sock, keyfile, certfile, ssl_version=PROTOCOL_TLSv1,
38 cert_reqs=CERT_REQUIRED, ca_certs=None):
38 cert_reqs=CERT_REQUIRED, ca_certs=None):
39 if not util.safehasattr(socket, 'ssl'):
39 if not util.safehasattr(socket, 'ssl'):
40 raise util.Abort(_('Python SSL support not found'))
40 raise util.Abort(_('Python SSL support not found'))
41 if ca_certs:
41 if ca_certs:
42 raise util.Abort(_(
42 raise util.Abort(_(
43 'certificate checking requires Python 2.6'))
43 'certificate checking requires Python 2.6'))
44
44
45 ssl = socket.ssl(sock, keyfile, certfile)
45 ssl = socket.ssl(sock, keyfile, certfile)
46 return httplib.FakeSocket(sock, ssl)
46 return httplib.FakeSocket(sock, ssl)
47
47
48 def _verifycert(cert, hostname):
48 def _verifycert(cert, hostname):
49 '''Verify that cert (in socket.getpeercert() format) matches hostname.
49 '''Verify that cert (in socket.getpeercert() format) matches hostname.
50 CRLs is not handled.
50 CRLs is not handled.
51
51
52 Returns error message if any problems are found and None on success.
52 Returns error message if any problems are found and None on success.
53 '''
53 '''
54 if not cert:
54 if not cert:
55 return _('no certificate received')
55 return _('no certificate received')
56 dnsname = hostname.lower()
56 dnsname = hostname.lower()
57 def matchdnsname(certname):
57 def matchdnsname(certname):
58 return (certname == dnsname or
58 return (certname == dnsname or
59 '.' in dnsname and certname == '*.' + dnsname.split('.', 1)[1])
59 '.' in dnsname and certname == '*.' + dnsname.split('.', 1)[1])
60
60
61 san = cert.get('subjectAltName', [])
61 san = cert.get('subjectAltName', [])
62 if san:
62 if san:
63 certnames = [value.lower() for key, value in san if key == 'DNS']
63 certnames = [value.lower() for key, value in san if key == 'DNS']
64 for name in certnames:
64 for name in certnames:
65 if matchdnsname(name):
65 if matchdnsname(name):
66 return None
66 return None
67 if certnames:
67 if certnames:
68 return _('certificate is for %s') % ', '.join(certnames)
68 return _('certificate is for %s') % ', '.join(certnames)
69
69
70 # subject is only checked when subjectAltName is empty
70 # subject is only checked when subjectAltName is empty
71 for s in cert.get('subject', []):
71 for s in cert.get('subject', []):
72 key, value = s[0]
72 key, value = s[0]
73 if key == 'commonName':
73 if key == 'commonName':
74 try:
74 try:
75 # 'subject' entries are unicode
75 # 'subject' entries are unicode
76 certname = value.lower().encode('ascii')
76 certname = value.lower().encode('ascii')
77 except UnicodeEncodeError:
77 except UnicodeEncodeError:
78 return _('IDN in certificate not supported')
78 return _('IDN in certificate not supported')
79 if matchdnsname(certname):
79 if matchdnsname(certname):
80 return None
80 return None
81 return _('certificate is for %s') % certname
81 return _('certificate is for %s') % certname
82 return _('no commonName or subjectAltName found in certificate')
82 return _('no commonName or subjectAltName found in certificate')
83
83
84
84
85 # CERT_REQUIRED means fetch the cert from the server all the time AND
85 # CERT_REQUIRED means fetch the cert from the server all the time AND
86 # validate it against the CA store provided in web.cacerts.
86 # validate it against the CA store provided in web.cacerts.
87 #
87 #
88 # We COMPLETELY ignore CERT_REQUIRED on Python <= 2.5, as it's totally
88 # We COMPLETELY ignore CERT_REQUIRED on Python <= 2.5, as it's totally
89 # busted on those versions.
89 # busted on those versions.
90
90
91 def _plainapplepython():
92 """return true if this seems to be a pure Apple Python that
93 * is unfrozen and presumably has the whole mercurial module in the file
94 system
95 * presumably is an Apple Python that uses Apple OpenSSL which has patches
96 for using system certificate store CAs in addition to the provided
97 cacerts file
98 """
99 if sys.platform != 'darwin' or util.mainfrozen():
100 return False
101 exe = (sys.executable or '').lower()
102 return (exe.startswith('/usr/bin/python') or
103 exe.startswith('/system/library/frameworks/python.framework/'))
104
91 def sslkwargs(ui, host):
105 def sslkwargs(ui, host):
92 forcetls = ui.configbool('ui', 'tls', default=True)
106 forcetls = ui.configbool('ui', 'tls', default=True)
93 if forcetls:
107 if forcetls:
94 ssl_version = PROTOCOL_TLSv1
108 ssl_version = PROTOCOL_TLSv1
95 else:
109 else:
96 ssl_version = PROTOCOL_SSLv23
110 ssl_version = PROTOCOL_SSLv23
97 kws = {'ssl_version': ssl_version,
111 kws = {'ssl_version': ssl_version,
98 }
112 }
99 hostfingerprint = ui.config('hostfingerprints', host)
113 hostfingerprint = ui.config('hostfingerprints', host)
100 if hostfingerprint:
114 if hostfingerprint:
101 return kws
115 return kws
102 cacerts = ui.config('web', 'cacerts')
116 cacerts = ui.config('web', 'cacerts')
103 if cacerts:
117 if cacerts:
104 cacerts = util.expandpath(cacerts)
118 cacerts = util.expandpath(cacerts)
105 if not os.path.exists(cacerts):
119 if not os.path.exists(cacerts):
106 raise util.Abort(_('could not find web.cacerts: %s') % cacerts)
120 raise util.Abort(_('could not find web.cacerts: %s') % cacerts)
107 elif cacerts is None and sys.platform == 'darwin' and not util.mainfrozen():
121 elif cacerts is None and _plainapplepython():
108 dummycert = os.path.join(os.path.dirname(__file__), 'dummycert.pem')
122 dummycert = os.path.join(os.path.dirname(__file__), 'dummycert.pem')
109 if os.path.exists(dummycert):
123 if os.path.exists(dummycert):
110 ui.debug('using %s to enable OS X system CA\n' % dummycert)
124 ui.debug('using %s to enable OS X system CA\n' % dummycert)
111 ui.setconfig('web', 'cacerts', dummycert, 'dummy')
125 ui.setconfig('web', 'cacerts', dummycert, 'dummy')
112 cacerts = dummycert
126 cacerts = dummycert
113 if cacerts:
127 if cacerts:
114 kws.update({'ca_certs': cacerts,
128 kws.update({'ca_certs': cacerts,
115 'cert_reqs': CERT_REQUIRED,
129 'cert_reqs': CERT_REQUIRED,
116 })
130 })
117 return kws
131 return kws
118
132
119 class validator(object):
133 class validator(object):
120 def __init__(self, ui, host):
134 def __init__(self, ui, host):
121 self.ui = ui
135 self.ui = ui
122 self.host = host
136 self.host = host
123
137
124 def __call__(self, sock, strict=False):
138 def __call__(self, sock, strict=False):
125 host = self.host
139 host = self.host
126 cacerts = self.ui.config('web', 'cacerts')
140 cacerts = self.ui.config('web', 'cacerts')
127 hostfingerprint = self.ui.config('hostfingerprints', host)
141 hostfingerprint = self.ui.config('hostfingerprints', host)
128 if not getattr(sock, 'getpeercert', False): # python 2.5 ?
142 if not getattr(sock, 'getpeercert', False): # python 2.5 ?
129 if hostfingerprint:
143 if hostfingerprint:
130 raise util.Abort(_("host fingerprint for %s can't be "
144 raise util.Abort(_("host fingerprint for %s can't be "
131 "verified (Python too old)") % host)
145 "verified (Python too old)") % host)
132 if strict:
146 if strict:
133 raise util.Abort(_("certificate for %s can't be verified "
147 raise util.Abort(_("certificate for %s can't be verified "
134 "(Python too old)") % host)
148 "(Python too old)") % host)
135 if self.ui.configbool('ui', 'reportoldssl', True):
149 if self.ui.configbool('ui', 'reportoldssl', True):
136 self.ui.warn(_("warning: certificate for %s can't be verified "
150 self.ui.warn(_("warning: certificate for %s can't be verified "
137 "(Python too old)\n") % host)
151 "(Python too old)\n") % host)
138 return
152 return
139
153
140 if not sock.cipher(): # work around http://bugs.python.org/issue13721
154 if not sock.cipher(): # work around http://bugs.python.org/issue13721
141 raise util.Abort(_('%s ssl connection error') % host)
155 raise util.Abort(_('%s ssl connection error') % host)
142 try:
156 try:
143 peercert = sock.getpeercert(True)
157 peercert = sock.getpeercert(True)
144 peercert2 = sock.getpeercert()
158 peercert2 = sock.getpeercert()
145 except AttributeError:
159 except AttributeError:
146 raise util.Abort(_('%s ssl connection error') % host)
160 raise util.Abort(_('%s ssl connection error') % host)
147
161
148 if not peercert:
162 if not peercert:
149 raise util.Abort(_('%s certificate error: '
163 raise util.Abort(_('%s certificate error: '
150 'no certificate received') % host)
164 'no certificate received') % host)
151 peerfingerprint = util.sha1(peercert).hexdigest()
165 peerfingerprint = util.sha1(peercert).hexdigest()
152 nicefingerprint = ":".join([peerfingerprint[x:x + 2]
166 nicefingerprint = ":".join([peerfingerprint[x:x + 2]
153 for x in xrange(0, len(peerfingerprint), 2)])
167 for x in xrange(0, len(peerfingerprint), 2)])
154 if hostfingerprint:
168 if hostfingerprint:
155 if peerfingerprint.lower() != \
169 if peerfingerprint.lower() != \
156 hostfingerprint.replace(':', '').lower():
170 hostfingerprint.replace(':', '').lower():
157 raise util.Abort(_('certificate for %s has unexpected '
171 raise util.Abort(_('certificate for %s has unexpected '
158 'fingerprint %s') % (host, nicefingerprint),
172 'fingerprint %s') % (host, nicefingerprint),
159 hint=_('check hostfingerprint configuration'))
173 hint=_('check hostfingerprint configuration'))
160 self.ui.debug('%s certificate matched fingerprint %s\n' %
174 self.ui.debug('%s certificate matched fingerprint %s\n' %
161 (host, nicefingerprint))
175 (host, nicefingerprint))
162 elif cacerts:
176 elif cacerts:
163 msg = _verifycert(peercert2, host)
177 msg = _verifycert(peercert2, host)
164 if msg:
178 if msg:
165 raise util.Abort(_('%s certificate error: %s') % (host, msg),
179 raise util.Abort(_('%s certificate error: %s') % (host, msg),
166 hint=_('configure hostfingerprint %s or use '
180 hint=_('configure hostfingerprint %s or use '
167 '--insecure to connect insecurely') %
181 '--insecure to connect insecurely') %
168 nicefingerprint)
182 nicefingerprint)
169 self.ui.debug('%s certificate successfully verified\n' % host)
183 self.ui.debug('%s certificate successfully verified\n' % host)
170 elif strict:
184 elif strict:
171 raise util.Abort(_('%s certificate with fingerprint %s not '
185 raise util.Abort(_('%s certificate with fingerprint %s not '
172 'verified') % (host, nicefingerprint),
186 'verified') % (host, nicefingerprint),
173 hint=_('check hostfingerprints or web.cacerts '
187 hint=_('check hostfingerprints or web.cacerts '
174 'config setting'))
188 'config setting'))
175 else:
189 else:
176 self.ui.warn(_('warning: %s certificate with fingerprint %s not '
190 self.ui.warn(_('warning: %s certificate with fingerprint %s not '
177 'verified (check hostfingerprints or web.cacerts '
191 'verified (check hostfingerprints or web.cacerts '
178 'config setting)\n') %
192 'config setting)\n') %
179 (host, nicefingerprint))
193 (host, nicefingerprint))
@@ -1,292 +1,293 b''
1 #require serve ssl
1 #require serve ssl
2
2
3 Proper https client requires the built-in ssl from Python 2.6.
3 Proper https client requires the built-in ssl from Python 2.6.
4
4
5 Certificates created with:
5 Certificates created with:
6 printf '.\n.\n.\n.\n.\nlocalhost\nhg@localhost\n' | \
6 printf '.\n.\n.\n.\n.\nlocalhost\nhg@localhost\n' | \
7 openssl req -newkey rsa:512 -keyout priv.pem -nodes -x509 -days 9000 -out pub.pem
7 openssl req -newkey rsa:512 -keyout priv.pem -nodes -x509 -days 9000 -out pub.pem
8 Can be dumped with:
8 Can be dumped with:
9 openssl x509 -in pub.pem -text
9 openssl x509 -in pub.pem -text
10
10
11 $ cat << EOT > priv.pem
11 $ cat << EOT > priv.pem
12 > -----BEGIN PRIVATE KEY-----
12 > -----BEGIN PRIVATE KEY-----
13 > MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEApjCWeYGrIa/Vo7LH
13 > MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEApjCWeYGrIa/Vo7LH
14 > aRF8ou0tbgHKE33Use/whCnKEUm34rDaXQd4lxxX6aDWg06n9tiVStAKTgQAHJY8
14 > aRF8ou0tbgHKE33Use/whCnKEUm34rDaXQd4lxxX6aDWg06n9tiVStAKTgQAHJY8
15 > j/xgSwIDAQABAkBxHC6+Qlf0VJXGlb6NL16yEVVTQxqDS6hA9zqu6TZjrr0YMfzc
15 > j/xgSwIDAQABAkBxHC6+Qlf0VJXGlb6NL16yEVVTQxqDS6hA9zqu6TZjrr0YMfzc
16 > EGNIiZGt7HCBL0zO+cPDg/LeCZc6HQhf0KrhAiEAzlJq4hWWzvguWFIJWSoBeBUG
16 > EGNIiZGt7HCBL0zO+cPDg/LeCZc6HQhf0KrhAiEAzlJq4hWWzvguWFIJWSoBeBUG
17 > MF1ACazQO7PYE8M0qfECIQDONHHP0SKZzz/ZwBZcAveC5K61f/v9hONFwbeYulzR
17 > MF1ACazQO7PYE8M0qfECIQDONHHP0SKZzz/ZwBZcAveC5K61f/v9hONFwbeYulzR
18 > +wIgc9SvbtgB/5Yzpp//4ZAEnR7oh5SClCvyB+KSx52K3nECICbhQphhoXmI10wy
18 > +wIgc9SvbtgB/5Yzpp//4ZAEnR7oh5SClCvyB+KSx52K3nECICbhQphhoXmI10wy
19 > aMTellaq0bpNMHFDziqH9RsqAHhjAiEAgYGxfzkftt5IUUn/iFK89aaIpyrpuaAh
19 > aMTellaq0bpNMHFDziqH9RsqAHhjAiEAgYGxfzkftt5IUUn/iFK89aaIpyrpuaAh
20 > HY8gUVkVRVs=
20 > HY8gUVkVRVs=
21 > -----END PRIVATE KEY-----
21 > -----END PRIVATE KEY-----
22 > EOT
22 > EOT
23
23
24 $ cat << EOT > pub.pem
24 $ cat << EOT > pub.pem
25 > -----BEGIN CERTIFICATE-----
25 > -----BEGIN CERTIFICATE-----
26 > MIIBqzCCAVWgAwIBAgIJANAXFFyWjGnRMA0GCSqGSIb3DQEBBQUAMDExEjAQBgNV
26 > MIIBqzCCAVWgAwIBAgIJANAXFFyWjGnRMA0GCSqGSIb3DQEBBQUAMDExEjAQBgNV
27 > BAMMCWxvY2FsaG9zdDEbMBkGCSqGSIb3DQEJARYMaGdAbG9jYWxob3N0MB4XDTEw
27 > BAMMCWxvY2FsaG9zdDEbMBkGCSqGSIb3DQEJARYMaGdAbG9jYWxob3N0MB4XDTEw
28 > MTAxNDIwMzAxNFoXDTM1MDYwNTIwMzAxNFowMTESMBAGA1UEAwwJbG9jYWxob3N0
28 > MTAxNDIwMzAxNFoXDTM1MDYwNTIwMzAxNFowMTESMBAGA1UEAwwJbG9jYWxob3N0
29 > MRswGQYJKoZIhvcNAQkBFgxoZ0Bsb2NhbGhvc3QwXDANBgkqhkiG9w0BAQEFAANL
29 > MRswGQYJKoZIhvcNAQkBFgxoZ0Bsb2NhbGhvc3QwXDANBgkqhkiG9w0BAQEFAANL
30 > ADBIAkEApjCWeYGrIa/Vo7LHaRF8ou0tbgHKE33Use/whCnKEUm34rDaXQd4lxxX
30 > ADBIAkEApjCWeYGrIa/Vo7LHaRF8ou0tbgHKE33Use/whCnKEUm34rDaXQd4lxxX
31 > 6aDWg06n9tiVStAKTgQAHJY8j/xgSwIDAQABo1AwTjAdBgNVHQ4EFgQUE6sA+amm
31 > 6aDWg06n9tiVStAKTgQAHJY8j/xgSwIDAQABo1AwTjAdBgNVHQ4EFgQUE6sA+amm
32 > r24dGX0kpjxOgO45hzQwHwYDVR0jBBgwFoAUE6sA+ammr24dGX0kpjxOgO45hzQw
32 > r24dGX0kpjxOgO45hzQwHwYDVR0jBBgwFoAUE6sA+ammr24dGX0kpjxOgO45hzQw
33 > DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAANBAFArvQFiAZJgQczRsbYlG1xl
33 > DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAANBAFArvQFiAZJgQczRsbYlG1xl
34 > t+truk37w5B3m3Ick1ntRcQrqs+hf0CO1q6Squ144geYaQ8CDirSR92fICELI1c=
34 > t+truk37w5B3m3Ick1ntRcQrqs+hf0CO1q6Squ144geYaQ8CDirSR92fICELI1c=
35 > -----END CERTIFICATE-----
35 > -----END CERTIFICATE-----
36 > EOT
36 > EOT
37 $ cat priv.pem pub.pem >> server.pem
37 $ cat priv.pem pub.pem >> server.pem
38 $ PRIV=`pwd`/server.pem
38 $ PRIV=`pwd`/server.pem
39
39
40 $ cat << EOT > pub-other.pem
40 $ cat << EOT > pub-other.pem
41 > -----BEGIN CERTIFICATE-----
41 > -----BEGIN CERTIFICATE-----
42 > MIIBqzCCAVWgAwIBAgIJALwZS731c/ORMA0GCSqGSIb3DQEBBQUAMDExEjAQBgNV
42 > MIIBqzCCAVWgAwIBAgIJALwZS731c/ORMA0GCSqGSIb3DQEBBQUAMDExEjAQBgNV
43 > BAMMCWxvY2FsaG9zdDEbMBkGCSqGSIb3DQEJARYMaGdAbG9jYWxob3N0MB4XDTEw
43 > BAMMCWxvY2FsaG9zdDEbMBkGCSqGSIb3DQEJARYMaGdAbG9jYWxob3N0MB4XDTEw
44 > MTAxNDIwNDUxNloXDTM1MDYwNTIwNDUxNlowMTESMBAGA1UEAwwJbG9jYWxob3N0
44 > MTAxNDIwNDUxNloXDTM1MDYwNTIwNDUxNlowMTESMBAGA1UEAwwJbG9jYWxob3N0
45 > MRswGQYJKoZIhvcNAQkBFgxoZ0Bsb2NhbGhvc3QwXDANBgkqhkiG9w0BAQEFAANL
45 > MRswGQYJKoZIhvcNAQkBFgxoZ0Bsb2NhbGhvc3QwXDANBgkqhkiG9w0BAQEFAANL
46 > ADBIAkEAsxsapLbHrqqUKuQBxdpK4G3m2LjtyrTSdpzzzFlecxd5yhNP6AyWrufo
46 > ADBIAkEAsxsapLbHrqqUKuQBxdpK4G3m2LjtyrTSdpzzzFlecxd5yhNP6AyWrufo
47 > K4VMGo2xlu9xOo88nDSUNSKPuD09MwIDAQABo1AwTjAdBgNVHQ4EFgQUoIB1iMhN
47 > K4VMGo2xlu9xOo88nDSUNSKPuD09MwIDAQABo1AwTjAdBgNVHQ4EFgQUoIB1iMhN
48 > y868rpQ2qk9dHnU6ebswHwYDVR0jBBgwFoAUoIB1iMhNy868rpQ2qk9dHnU6ebsw
48 > y868rpQ2qk9dHnU6ebswHwYDVR0jBBgwFoAUoIB1iMhNy868rpQ2qk9dHnU6ebsw
49 > DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAANBAJ544f125CsE7J2t55PdFaF6
49 > DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAANBAJ544f125CsE7J2t55PdFaF6
50 > bBlNBb91FCywBgSjhBjf+GG3TNPwrPdc3yqeq+hzJiuInqbOBv9abmMyq8Wsoig=
50 > bBlNBb91FCywBgSjhBjf+GG3TNPwrPdc3yqeq+hzJiuInqbOBv9abmMyq8Wsoig=
51 > -----END CERTIFICATE-----
51 > -----END CERTIFICATE-----
52 > EOT
52 > EOT
53
53
54 pub.pem patched with other notBefore / notAfter:
54 pub.pem patched with other notBefore / notAfter:
55
55
56 $ cat << EOT > pub-not-yet.pem
56 $ cat << EOT > pub-not-yet.pem
57 > -----BEGIN CERTIFICATE-----
57 > -----BEGIN CERTIFICATE-----
58 > MIIBqzCCAVWgAwIBAgIJANAXFFyWjGnRMA0GCSqGSIb3DQEBBQUAMDExEjAQBgNVBAMMCWxvY2Fs
58 > MIIBqzCCAVWgAwIBAgIJANAXFFyWjGnRMA0GCSqGSIb3DQEBBQUAMDExEjAQBgNVBAMMCWxvY2Fs
59 > aG9zdDEbMBkGCSqGSIb3DQEJARYMaGdAbG9jYWxob3N0MB4XDTM1MDYwNTIwMzAxNFoXDTM1MDYw
59 > aG9zdDEbMBkGCSqGSIb3DQEJARYMaGdAbG9jYWxob3N0MB4XDTM1MDYwNTIwMzAxNFoXDTM1MDYw
60 > NTIwMzAxNFowMTESMBAGA1UEAwwJbG9jYWxob3N0MRswGQYJKoZIhvcNAQkBFgxoZ0Bsb2NhbGhv
60 > NTIwMzAxNFowMTESMBAGA1UEAwwJbG9jYWxob3N0MRswGQYJKoZIhvcNAQkBFgxoZ0Bsb2NhbGhv
61 > c3QwXDANBgkqhkiG9w0BAQEFAANLADBIAkEApjCWeYGrIa/Vo7LHaRF8ou0tbgHKE33Use/whCnK
61 > c3QwXDANBgkqhkiG9w0BAQEFAANLADBIAkEApjCWeYGrIa/Vo7LHaRF8ou0tbgHKE33Use/whCnK
62 > EUm34rDaXQd4lxxX6aDWg06n9tiVStAKTgQAHJY8j/xgSwIDAQABo1AwTjAdBgNVHQ4EFgQUE6sA
62 > EUm34rDaXQd4lxxX6aDWg06n9tiVStAKTgQAHJY8j/xgSwIDAQABo1AwTjAdBgNVHQ4EFgQUE6sA
63 > +ammr24dGX0kpjxOgO45hzQwHwYDVR0jBBgwFoAUE6sA+ammr24dGX0kpjxOgO45hzQwDAYDVR0T
63 > +ammr24dGX0kpjxOgO45hzQwHwYDVR0jBBgwFoAUE6sA+ammr24dGX0kpjxOgO45hzQwDAYDVR0T
64 > BAUwAwEB/zANBgkqhkiG9w0BAQUFAANBAJXV41gWnkgC7jcpPpFRSUSZaxyzrXmD1CIqQf0WgVDb
64 > BAUwAwEB/zANBgkqhkiG9w0BAQUFAANBAJXV41gWnkgC7jcpPpFRSUSZaxyzrXmD1CIqQf0WgVDb
65 > /12E0vR2DuZitgzUYtBaofM81aTtc0a2/YsrmqePGm0=
65 > /12E0vR2DuZitgzUYtBaofM81aTtc0a2/YsrmqePGm0=
66 > -----END CERTIFICATE-----
66 > -----END CERTIFICATE-----
67 > EOT
67 > EOT
68 $ cat priv.pem pub-not-yet.pem > server-not-yet.pem
68 $ cat priv.pem pub-not-yet.pem > server-not-yet.pem
69
69
70 $ cat << EOT > pub-expired.pem
70 $ cat << EOT > pub-expired.pem
71 > -----BEGIN CERTIFICATE-----
71 > -----BEGIN CERTIFICATE-----
72 > MIIBqzCCAVWgAwIBAgIJANAXFFyWjGnRMA0GCSqGSIb3DQEBBQUAMDExEjAQBgNVBAMMCWxvY2Fs
72 > MIIBqzCCAVWgAwIBAgIJANAXFFyWjGnRMA0GCSqGSIb3DQEBBQUAMDExEjAQBgNVBAMMCWxvY2Fs
73 > aG9zdDEbMBkGCSqGSIb3DQEJARYMaGdAbG9jYWxob3N0MB4XDTEwMTAxNDIwMzAxNFoXDTEwMTAx
73 > aG9zdDEbMBkGCSqGSIb3DQEJARYMaGdAbG9jYWxob3N0MB4XDTEwMTAxNDIwMzAxNFoXDTEwMTAx
74 > NDIwMzAxNFowMTESMBAGA1UEAwwJbG9jYWxob3N0MRswGQYJKoZIhvcNAQkBFgxoZ0Bsb2NhbGhv
74 > NDIwMzAxNFowMTESMBAGA1UEAwwJbG9jYWxob3N0MRswGQYJKoZIhvcNAQkBFgxoZ0Bsb2NhbGhv
75 > c3QwXDANBgkqhkiG9w0BAQEFAANLADBIAkEApjCWeYGrIa/Vo7LHaRF8ou0tbgHKE33Use/whCnK
75 > c3QwXDANBgkqhkiG9w0BAQEFAANLADBIAkEApjCWeYGrIa/Vo7LHaRF8ou0tbgHKE33Use/whCnK
76 > EUm34rDaXQd4lxxX6aDWg06n9tiVStAKTgQAHJY8j/xgSwIDAQABo1AwTjAdBgNVHQ4EFgQUE6sA
76 > EUm34rDaXQd4lxxX6aDWg06n9tiVStAKTgQAHJY8j/xgSwIDAQABo1AwTjAdBgNVHQ4EFgQUE6sA
77 > +ammr24dGX0kpjxOgO45hzQwHwYDVR0jBBgwFoAUE6sA+ammr24dGX0kpjxOgO45hzQwDAYDVR0T
77 > +ammr24dGX0kpjxOgO45hzQwHwYDVR0jBBgwFoAUE6sA+ammr24dGX0kpjxOgO45hzQwDAYDVR0T
78 > BAUwAwEB/zANBgkqhkiG9w0BAQUFAANBAJfk57DTRf2nUbYaMSlVAARxMNbFGOjQhAUtY400GhKt
78 > BAUwAwEB/zANBgkqhkiG9w0BAQUFAANBAJfk57DTRf2nUbYaMSlVAARxMNbFGOjQhAUtY400GhKt
79 > 2uiKCNGKXVXD3AHWe13yHc5KttzbHQStE5Nm/DlWBWQ=
79 > 2uiKCNGKXVXD3AHWe13yHc5KttzbHQStE5Nm/DlWBWQ=
80 > -----END CERTIFICATE-----
80 > -----END CERTIFICATE-----
81 > EOT
81 > EOT
82 $ cat priv.pem pub-expired.pem > server-expired.pem
82 $ cat priv.pem pub-expired.pem > server-expired.pem
83
83
84 $ hg init test
84 $ hg init test
85 $ cd test
85 $ cd test
86 $ echo foo>foo
86 $ echo foo>foo
87 $ mkdir foo.d foo.d/bAr.hg.d foo.d/baR.d.hg
87 $ mkdir foo.d foo.d/bAr.hg.d foo.d/baR.d.hg
88 $ echo foo>foo.d/foo
88 $ echo foo>foo.d/foo
89 $ echo bar>foo.d/bAr.hg.d/BaR
89 $ echo bar>foo.d/bAr.hg.d/BaR
90 $ echo bar>foo.d/baR.d.hg/bAR
90 $ echo bar>foo.d/baR.d.hg/bAR
91 $ hg commit -A -m 1
91 $ hg commit -A -m 1
92 adding foo
92 adding foo
93 adding foo.d/bAr.hg.d/BaR
93 adding foo.d/bAr.hg.d/BaR
94 adding foo.d/baR.d.hg/bAR
94 adding foo.d/baR.d.hg/bAR
95 adding foo.d/foo
95 adding foo.d/foo
96 $ hg serve -p $HGPORT -d --pid-file=../hg0.pid --certificate=$PRIV
96 $ hg serve -p $HGPORT -d --pid-file=../hg0.pid --certificate=$PRIV
97 $ cat ../hg0.pid >> $DAEMON_PIDS
97 $ cat ../hg0.pid >> $DAEMON_PIDS
98
98
99 cacert not found
99 cacert not found
100
100
101 $ hg in --config web.cacerts=no-such.pem https://localhost:$HGPORT/
101 $ hg in --config web.cacerts=no-such.pem https://localhost:$HGPORT/
102 abort: could not find web.cacerts: no-such.pem
102 abort: could not find web.cacerts: no-such.pem
103 [255]
103 [255]
104
104
105 Test server address cannot be reused
105 Test server address cannot be reused
106
106
107 #if windows
107 #if windows
108 $ hg serve -p $HGPORT --certificate=$PRIV 2>&1
108 $ hg serve -p $HGPORT --certificate=$PRIV 2>&1
109 abort: cannot start server at ':$HGPORT':
109 abort: cannot start server at ':$HGPORT':
110 [255]
110 [255]
111 #else
111 #else
112 $ hg serve -p $HGPORT --certificate=$PRIV 2>&1
112 $ hg serve -p $HGPORT --certificate=$PRIV 2>&1
113 abort: cannot start server at ':$HGPORT': Address already in use
113 abort: cannot start server at ':$HGPORT': Address already in use
114 [255]
114 [255]
115 #endif
115 #endif
116 $ cd ..
116 $ cd ..
117
117
118 OS X has a dummy CA cert that enables use of the system CA store
118 OS X has a dummy CA cert that enables use of the system CA store when using
119 Apple's OpenSSL. This trick do not work with plain OpenSSL.
119
120
120 $ DISABLEOSXDUMMYCERT=
121 $ DISABLEOSXDUMMYCERT=
121 #if osx
122 #if osx
122 $ hg clone https://localhost:$HGPORT/ copy-pull
123 $ hg clone https://localhost:$HGPORT/ copy-pull
123 abort: error: *:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (glob)
124 abort: error: *:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (glob)
124 [255]
125 [255]
125
126
126 $ DISABLEOSXDUMMYCERT="--config=web.cacerts="
127 $ DISABLEOSXDUMMYCERT="--config=web.cacerts="
127 #endif
128 #endif
128
129
129 clone via pull
130 clone via pull
130
131
131 $ hg clone https://localhost:$HGPORT/ copy-pull $DISABLEOSXDUMMYCERT
132 $ hg clone https://localhost:$HGPORT/ copy-pull $DISABLEOSXDUMMYCERT
132 warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting)
133 warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting)
133 requesting all changes
134 requesting all changes
134 adding changesets
135 adding changesets
135 adding manifests
136 adding manifests
136 adding file changes
137 adding file changes
137 added 1 changesets with 4 changes to 4 files
138 added 1 changesets with 4 changes to 4 files
138 updating to branch default
139 updating to branch default
139 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
140 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
140 $ hg verify -R copy-pull
141 $ hg verify -R copy-pull
141 checking changesets
142 checking changesets
142 checking manifests
143 checking manifests
143 crosschecking files in changesets and manifests
144 crosschecking files in changesets and manifests
144 checking files
145 checking files
145 4 files, 1 changesets, 4 total revisions
146 4 files, 1 changesets, 4 total revisions
146 $ cd test
147 $ cd test
147 $ echo bar > bar
148 $ echo bar > bar
148 $ hg commit -A -d '1 0' -m 2
149 $ hg commit -A -d '1 0' -m 2
149 adding bar
150 adding bar
150 $ cd ..
151 $ cd ..
151
152
152 pull without cacert
153 pull without cacert
153
154
154 $ cd copy-pull
155 $ cd copy-pull
155 $ echo '[hooks]' >> .hg/hgrc
156 $ echo '[hooks]' >> .hg/hgrc
156 $ echo "changegroup = python \"$TESTDIR/printenv.py\" changegroup" >> .hg/hgrc
157 $ echo "changegroup = python \"$TESTDIR/printenv.py\" changegroup" >> .hg/hgrc
157 $ hg pull $DISABLEOSXDUMMYCERT
158 $ hg pull $DISABLEOSXDUMMYCERT
158 warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting)
159 warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting)
159 pulling from https://localhost:$HGPORT/
160 pulling from https://localhost:$HGPORT/
160 searching for changes
161 searching for changes
161 adding changesets
162 adding changesets
162 adding manifests
163 adding manifests
163 adding file changes
164 adding file changes
164 added 1 changesets with 1 changes to 1 files
165 added 1 changesets with 1 changes to 1 files
165 changegroup hook: HG_NODE=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_SOURCE=pull HG_URL=https://localhost:$HGPORT/
166 changegroup hook: HG_NODE=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_SOURCE=pull HG_URL=https://localhost:$HGPORT/
166 (run 'hg update' to get a working copy)
167 (run 'hg update' to get a working copy)
167 $ cd ..
168 $ cd ..
168
169
169 cacert configured in local repo
170 cacert configured in local repo
170
171
171 $ cp copy-pull/.hg/hgrc copy-pull/.hg/hgrc.bu
172 $ cp copy-pull/.hg/hgrc copy-pull/.hg/hgrc.bu
172 $ echo "[web]" >> copy-pull/.hg/hgrc
173 $ echo "[web]" >> copy-pull/.hg/hgrc
173 $ echo "cacerts=`pwd`/pub.pem" >> copy-pull/.hg/hgrc
174 $ echo "cacerts=`pwd`/pub.pem" >> copy-pull/.hg/hgrc
174 $ hg -R copy-pull pull --traceback
175 $ hg -R copy-pull pull --traceback
175 pulling from https://localhost:$HGPORT/
176 pulling from https://localhost:$HGPORT/
176 searching for changes
177 searching for changes
177 no changes found
178 no changes found
178 $ mv copy-pull/.hg/hgrc.bu copy-pull/.hg/hgrc
179 $ mv copy-pull/.hg/hgrc.bu copy-pull/.hg/hgrc
179
180
180 cacert configured globally, also testing expansion of environment
181 cacert configured globally, also testing expansion of environment
181 variables in the filename
182 variables in the filename
182
183
183 $ echo "[web]" >> $HGRCPATH
184 $ echo "[web]" >> $HGRCPATH
184 $ echo 'cacerts=$P/pub.pem' >> $HGRCPATH
185 $ echo 'cacerts=$P/pub.pem' >> $HGRCPATH
185 $ P=`pwd` hg -R copy-pull pull
186 $ P=`pwd` hg -R copy-pull pull
186 pulling from https://localhost:$HGPORT/
187 pulling from https://localhost:$HGPORT/
187 searching for changes
188 searching for changes
188 no changes found
189 no changes found
189 $ P=`pwd` hg -R copy-pull pull --insecure
190 $ P=`pwd` hg -R copy-pull pull --insecure
190 warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting)
191 warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting)
191 pulling from https://localhost:$HGPORT/
192 pulling from https://localhost:$HGPORT/
192 searching for changes
193 searching for changes
193 no changes found
194 no changes found
194
195
195 cacert mismatch
196 cacert mismatch
196
197
197 $ hg -R copy-pull pull --config web.cacerts=pub.pem https://127.0.0.1:$HGPORT/
198 $ hg -R copy-pull pull --config web.cacerts=pub.pem https://127.0.0.1:$HGPORT/
198 abort: 127.0.0.1 certificate error: certificate is for localhost
199 abort: 127.0.0.1 certificate error: certificate is for localhost
199 (configure hostfingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca or use --insecure to connect insecurely)
200 (configure hostfingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca or use --insecure to connect insecurely)
200 [255]
201 [255]
201 $ hg -R copy-pull pull --config web.cacerts=pub.pem https://127.0.0.1:$HGPORT/ --insecure
202 $ hg -R copy-pull pull --config web.cacerts=pub.pem https://127.0.0.1:$HGPORT/ --insecure
202 warning: 127.0.0.1 certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting)
203 warning: 127.0.0.1 certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting)
203 pulling from https://127.0.0.1:$HGPORT/
204 pulling from https://127.0.0.1:$HGPORT/
204 searching for changes
205 searching for changes
205 no changes found
206 no changes found
206 $ hg -R copy-pull pull --config web.cacerts=pub-other.pem
207 $ hg -R copy-pull pull --config web.cacerts=pub-other.pem
207 abort: error: *:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (glob)
208 abort: error: *:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (glob)
208 [255]
209 [255]
209 $ hg -R copy-pull pull --config web.cacerts=pub-other.pem --insecure
210 $ hg -R copy-pull pull --config web.cacerts=pub-other.pem --insecure
210 warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting)
211 warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting)
211 pulling from https://localhost:$HGPORT/
212 pulling from https://localhost:$HGPORT/
212 searching for changes
213 searching for changes
213 no changes found
214 no changes found
214
215
215 Test server cert which isn't valid yet
216 Test server cert which isn't valid yet
216
217
217 $ hg -R test serve -p $HGPORT1 -d --pid-file=hg1.pid --certificate=server-not-yet.pem
218 $ hg -R test serve -p $HGPORT1 -d --pid-file=hg1.pid --certificate=server-not-yet.pem
218 $ cat hg1.pid >> $DAEMON_PIDS
219 $ cat hg1.pid >> $DAEMON_PIDS
219 $ hg -R copy-pull pull --config web.cacerts=pub-not-yet.pem https://localhost:$HGPORT1/
220 $ hg -R copy-pull pull --config web.cacerts=pub-not-yet.pem https://localhost:$HGPORT1/
220 abort: error: *:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (glob)
221 abort: error: *:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (glob)
221 [255]
222 [255]
222
223
223 Test server cert which no longer is valid
224 Test server cert which no longer is valid
224
225
225 $ hg -R test serve -p $HGPORT2 -d --pid-file=hg2.pid --certificate=server-expired.pem
226 $ hg -R test serve -p $HGPORT2 -d --pid-file=hg2.pid --certificate=server-expired.pem
226 $ cat hg2.pid >> $DAEMON_PIDS
227 $ cat hg2.pid >> $DAEMON_PIDS
227 $ hg -R copy-pull pull --config web.cacerts=pub-expired.pem https://localhost:$HGPORT2/
228 $ hg -R copy-pull pull --config web.cacerts=pub-expired.pem https://localhost:$HGPORT2/
228 abort: error: *:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (glob)
229 abort: error: *:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (glob)
229 [255]
230 [255]
230
231
231 Fingerprints
232 Fingerprints
232
233
233 $ echo "[hostfingerprints]" >> copy-pull/.hg/hgrc
234 $ echo "[hostfingerprints]" >> copy-pull/.hg/hgrc
234 $ echo "localhost = 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca" >> copy-pull/.hg/hgrc
235 $ echo "localhost = 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca" >> copy-pull/.hg/hgrc
235 $ echo "127.0.0.1 = 914f1aff87249c09b6859b88b1906d30756491ca" >> copy-pull/.hg/hgrc
236 $ echo "127.0.0.1 = 914f1aff87249c09b6859b88b1906d30756491ca" >> copy-pull/.hg/hgrc
236
237
237 - works without cacerts
238 - works without cacerts
238 $ hg -R copy-pull id https://localhost:$HGPORT/ --config web.cacerts=
239 $ hg -R copy-pull id https://localhost:$HGPORT/ --config web.cacerts=
239 5fed3813f7f5
240 5fed3813f7f5
240
241
241 - fails when cert doesn't match hostname (port is ignored)
242 - fails when cert doesn't match hostname (port is ignored)
242 $ hg -R copy-pull id https://localhost:$HGPORT1/
243 $ hg -R copy-pull id https://localhost:$HGPORT1/
243 abort: certificate for localhost has unexpected fingerprint 28:ff:71:bf:65:31:14:23:ad:62:92:b4:0e:31:99:18:fc:83:e3:9b
244 abort: certificate for localhost has unexpected fingerprint 28:ff:71:bf:65:31:14:23:ad:62:92:b4:0e:31:99:18:fc:83:e3:9b
244 (check hostfingerprint configuration)
245 (check hostfingerprint configuration)
245 [255]
246 [255]
246
247
247
248
248 - ignores that certificate doesn't match hostname
249 - ignores that certificate doesn't match hostname
249 $ hg -R copy-pull id https://127.0.0.1:$HGPORT/
250 $ hg -R copy-pull id https://127.0.0.1:$HGPORT/
250 5fed3813f7f5
251 5fed3813f7f5
251
252
252 HGPORT1 is reused below for tinyproxy tests. Kill that server.
253 HGPORT1 is reused below for tinyproxy tests. Kill that server.
253 $ "$TESTDIR/killdaemons.py" hg1.pid
254 $ "$TESTDIR/killdaemons.py" hg1.pid
254
255
255 Prepare for connecting through proxy
256 Prepare for connecting through proxy
256
257
257 $ "$TESTDIR/tinyproxy.py" $HGPORT1 localhost >proxy.log </dev/null 2>&1 &
258 $ "$TESTDIR/tinyproxy.py" $HGPORT1 localhost >proxy.log </dev/null 2>&1 &
258 $ while [ ! -f proxy.pid ]; do sleep 0; done
259 $ while [ ! -f proxy.pid ]; do sleep 0; done
259 $ cat proxy.pid >> $DAEMON_PIDS
260 $ cat proxy.pid >> $DAEMON_PIDS
260
261
261 $ echo "[http_proxy]" >> copy-pull/.hg/hgrc
262 $ echo "[http_proxy]" >> copy-pull/.hg/hgrc
262 $ echo "always=True" >> copy-pull/.hg/hgrc
263 $ echo "always=True" >> copy-pull/.hg/hgrc
263 $ echo "[hostfingerprints]" >> copy-pull/.hg/hgrc
264 $ echo "[hostfingerprints]" >> copy-pull/.hg/hgrc
264 $ echo "localhost =" >> copy-pull/.hg/hgrc
265 $ echo "localhost =" >> copy-pull/.hg/hgrc
265
266
266 Test unvalidated https through proxy
267 Test unvalidated https through proxy
267
268
268 $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull --insecure --traceback
269 $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull --insecure --traceback
269 warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting)
270 warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting)
270 pulling from https://localhost:$HGPORT/
271 pulling from https://localhost:$HGPORT/
271 searching for changes
272 searching for changes
272 no changes found
273 no changes found
273
274
274 Test https with cacert and fingerprint through proxy
275 Test https with cacert and fingerprint through proxy
275
276
276 $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull --config web.cacerts=pub.pem
277 $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull --config web.cacerts=pub.pem
277 pulling from https://localhost:$HGPORT/
278 pulling from https://localhost:$HGPORT/
278 searching for changes
279 searching for changes
279 no changes found
280 no changes found
280 $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull https://127.0.0.1:$HGPORT/
281 $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull https://127.0.0.1:$HGPORT/
281 pulling from https://127.0.0.1:$HGPORT/
282 pulling from https://127.0.0.1:$HGPORT/
282 searching for changes
283 searching for changes
283 no changes found
284 no changes found
284
285
285 Test https with cert problems through proxy
286 Test https with cert problems through proxy
286
287
287 $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull --config web.cacerts=pub-other.pem
288 $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull --config web.cacerts=pub-other.pem
288 abort: error: *:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (glob)
289 abort: error: *:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (glob)
289 [255]
290 [255]
290 $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull --config web.cacerts=pub-expired.pem https://localhost:$HGPORT2/
291 $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull --config web.cacerts=pub-expired.pem https://localhost:$HGPORT2/
291 abort: error: *:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (glob)
292 abort: error: *:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (glob)
292 [255]
293 [255]
General Comments 0
You need to be logged in to leave comments. Login now