##// END OF EJS Templates
test: override default cipher selection when connecting to TLS 1.0/1.1 servers...
Julien Cristau -
r49932:7ea2bd20 default
parent child Browse files
Show More
@@ -1,554 +1,555 b''
1 1 #require serve ssl
2 2
3 3 Proper https client requires the built-in ssl from Python 2.6.
4 4
5 5 Disable the system configuration which may set stricter TLS requirements.
6 6 This test expects that legacy TLS versions are supported.
7 7
8 8 $ OPENSSL_CONF=
9 9 $ export OPENSSL_CONF
10 10
11 11 Make server certificates:
12 12
13 13 $ CERTSDIR="$TESTDIR/sslcerts"
14 14 $ cat "$CERTSDIR/priv.pem" "$CERTSDIR/pub.pem" >> server.pem
15 15 $ PRIV=`pwd`/server.pem
16 16 $ cat "$CERTSDIR/priv.pem" "$CERTSDIR/pub-not-yet.pem" > server-not-yet.pem
17 17 $ cat "$CERTSDIR/priv.pem" "$CERTSDIR/pub-expired.pem" > server-expired.pem
18 18
19 19 $ hg init test
20 20 $ cd test
21 21 $ echo foo>foo
22 22 $ mkdir foo.d foo.d/bAr.hg.d foo.d/baR.d.hg
23 23 $ echo foo>foo.d/foo
24 24 $ echo bar>foo.d/bAr.hg.d/BaR
25 25 $ echo bar>foo.d/baR.d.hg/bAR
26 26 $ hg commit -A -m 1
27 27 adding foo
28 28 adding foo.d/bAr.hg.d/BaR
29 29 adding foo.d/baR.d.hg/bAR
30 30 adding foo.d/foo
31 31 $ hg serve -p $HGPORT -d --pid-file=../hg0.pid --certificate=$PRIV
32 32 $ cat ../hg0.pid >> $DAEMON_PIDS
33 33
34 34 cacert not found
35 35
36 36 $ hg in --config web.cacerts=no-such.pem https://localhost:$HGPORT/
37 37 abort: could not find web.cacerts: no-such.pem
38 38 [255]
39 39
40 40 Test server address cannot be reused
41 41
42 42 $ hg serve -p $HGPORT --certificate=$PRIV 2>&1
43 43 abort: cannot start server at 'localhost:$HGPORT': $EADDRINUSE$
44 44 [255]
45 45
46 46 $ cd ..
47 47
48 48 Our test cert is not signed by a trusted CA. It should fail to verify if
49 49 we are able to load CA certs.
50 50
51 51 #if no-defaultcacertsloaded
52 52 $ hg clone https://localhost:$HGPORT/ copy-pull
53 53 (an attempt was made to load CA certificates but none were loaded; see https://mercurial-scm.org/wiki/SecureConnections for how to configure Mercurial to avoid this error)
54 54 abort: error: *certificate verify failed* (glob)
55 55 [100]
56 56 #endif
57 57
58 58 #if defaultcacertsloaded
59 59 $ hg clone https://localhost:$HGPORT/ copy-pull
60 60 (the full certificate chain may not be available locally; see "hg help debugssl") (windows !)
61 61 abort: error: *certificate verify failed* (glob)
62 62 [100]
63 63 #endif
64 64
65 65 Specifying a per-host certificate file that doesn't exist will abort. The full
66 66 C:/path/to/msysroot will print on Windows.
67 67
68 68 $ hg --config hostsecurity.localhost:verifycertsfile=/does/not/exist clone https://localhost:$HGPORT/
69 69 abort: path specified by hostsecurity.localhost:verifycertsfile does not exist: */does/not/exist (glob)
70 70 [255]
71 71
72 72 A malformed per-host certificate file will raise an error
73 73
74 74 $ echo baddata > badca.pem
75 75 $ hg --config hostsecurity.localhost:verifycertsfile=badca.pem clone https://localhost:$HGPORT/
76 76 abort: error loading CA file badca.pem: * (glob)
77 77 (file is empty or malformed?)
78 78 [255]
79 79
80 80 A per-host certificate mismatching the server will fail verification
81 81
82 82 (modern ssl is able to discern whether the loaded cert is a CA cert)
83 83 $ hg --config hostsecurity.localhost:verifycertsfile="$CERTSDIR/client-cert.pem" clone https://localhost:$HGPORT/
84 84 (an attempt was made to load CA certificates but none were loaded; see https://mercurial-scm.org/wiki/SecureConnections for how to configure Mercurial to avoid this error)
85 85 (the full certificate chain may not be available locally; see "hg help debugssl") (windows !)
86 86 abort: error: *certificate verify failed* (glob)
87 87 [100]
88 88
89 89 A per-host certificate matching the server's cert will be accepted
90 90
91 91 $ hg --config hostsecurity.localhost:verifycertsfile="$CERTSDIR/pub.pem" clone -U https://localhost:$HGPORT/ perhostgood1
92 92 requesting all changes
93 93 adding changesets
94 94 adding manifests
95 95 adding file changes
96 96 added 1 changesets with 4 changes to 4 files
97 97 new changesets 8b6053c928fe
98 98
99 99 A per-host certificate with multiple certs and one matching will be accepted
100 100
101 101 $ cat "$CERTSDIR/client-cert.pem" "$CERTSDIR/pub.pem" > perhost.pem
102 102 $ hg --config hostsecurity.localhost:verifycertsfile=perhost.pem clone -U https://localhost:$HGPORT/ perhostgood2
103 103 requesting all changes
104 104 adding changesets
105 105 adding manifests
106 106 adding file changes
107 107 added 1 changesets with 4 changes to 4 files
108 108 new changesets 8b6053c928fe
109 109
110 110 Defining both per-host certificate and a fingerprint will print a warning
111 111
112 112 $ hg --config hostsecurity.localhost:verifycertsfile="$CERTSDIR/pub.pem" --config hostsecurity.localhost:fingerprints=sha1:ecd87cd6b386d04fc1b8b41c9d8f5e168eef1c03 clone -U https://localhost:$HGPORT/ caandfingerwarning
113 113 (hostsecurity.localhost:verifycertsfile ignored when host fingerprints defined; using host fingerprints for verification)
114 114 requesting all changes
115 115 adding changesets
116 116 adding manifests
117 117 adding file changes
118 118 added 1 changesets with 4 changes to 4 files
119 119 new changesets 8b6053c928fe
120 120
121 121 $ DISABLECACERTS="--config devel.disableloaddefaultcerts=true"
122 122
123 123 Inability to verify peer certificate will result in abort
124 124
125 125 $ hg clone https://localhost:$HGPORT/ copy-pull $DISABLECACERTS
126 126 abort: unable to verify security of localhost (no loaded CA certificates); refusing to connect
127 127 (see https://mercurial-scm.org/wiki/SecureConnections for how to configure Mercurial to avoid this error or set hostsecurity.localhost:fingerprints=sha256:20:de:b3:ad:b4:cd:a5:42:f0:74:41:1c:a2:70:1e:da:6e:c0:5c:16:9e:e7:22:0f:f1:b7:e5:6e:e4:92:af:7e to trust this server)
128 128 [150]
129 129
130 130 $ hg clone --insecure https://localhost:$HGPORT/ copy-pull
131 131 warning: connection security to localhost is disabled per current settings; communication is susceptible to eavesdropping and tampering
132 132 requesting all changes
133 133 adding changesets
134 134 adding manifests
135 135 adding file changes
136 136 added 1 changesets with 4 changes to 4 files
137 137 new changesets 8b6053c928fe
138 138 updating to branch default
139 139 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
140 140 $ hg verify -R copy-pull
141 141 checking changesets
142 142 checking manifests
143 143 crosschecking files in changesets and manifests
144 144 checking files
145 145 checked 1 changesets with 4 changes to 4 files
146 146 $ cd test
147 147 $ echo bar > bar
148 148 $ hg commit -A -d '1 0' -m 2
149 149 adding bar
150 150 $ cd ..
151 151
152 152 pull without cacert
153 153
154 154 $ cd copy-pull
155 155 $ cat >> .hg/hgrc <<EOF
156 156 > [hooks]
157 157 > changegroup = sh -c "printenv.py --line changegroup"
158 158 > EOF
159 159 $ hg pull $DISABLECACERTS
160 160 pulling from https://localhost:$HGPORT/
161 161 abort: unable to verify security of localhost (no loaded CA certificates); refusing to connect
162 162 (see https://mercurial-scm.org/wiki/SecureConnections for how to configure Mercurial to avoid this error or set hostsecurity.localhost:fingerprints=sha256:20:de:b3:ad:b4:cd:a5:42:f0:74:41:1c:a2:70:1e:da:6e:c0:5c:16:9e:e7:22:0f:f1:b7:e5:6e:e4:92:af:7e to trust this server)
163 163 [150]
164 164
165 165 $ hg pull --insecure
166 166 pulling from https://localhost:$HGPORT/
167 167 warning: connection security to localhost is disabled per current settings; communication is susceptible to eavesdropping and tampering
168 168 searching for changes
169 169 adding changesets
170 170 adding manifests
171 171 adding file changes
172 172 added 1 changesets with 1 changes to 1 files
173 173 new changesets 5fed3813f7f5
174 174 changegroup hook: HG_HOOKNAME=changegroup
175 175 HG_HOOKTYPE=changegroup
176 176 HG_NODE=5fed3813f7f5e1824344fdc9cf8f63bb662c292d
177 177 HG_NODE_LAST=5fed3813f7f5e1824344fdc9cf8f63bb662c292d
178 178 HG_SOURCE=pull
179 179 HG_TXNID=TXN:$ID$
180 180 HG_TXNNAME=pull
181 181 https://localhost:$HGPORT/
182 182 HG_URL=https://localhost:$HGPORT/
183 183
184 184 (run 'hg update' to get a working copy)
185 185 $ cd ..
186 186
187 187 cacert configured in local repo
188 188
189 189 $ cp copy-pull/.hg/hgrc copy-pull/.hg/hgrc.bu
190 190 $ echo "[web]" >> copy-pull/.hg/hgrc
191 191 $ echo "cacerts=$CERTSDIR/pub.pem" >> copy-pull/.hg/hgrc
192 192 $ hg -R copy-pull pull
193 193 pulling from https://localhost:$HGPORT/
194 194 searching for changes
195 195 no changes found
196 196 $ mv copy-pull/.hg/hgrc.bu copy-pull/.hg/hgrc
197 197
198 198 cacert configured globally, also testing expansion of environment
199 199 variables in the filename
200 200
201 201 $ echo "[web]" >> $HGRCPATH
202 202 $ echo 'cacerts=$P/pub.pem' >> $HGRCPATH
203 203 $ P="$CERTSDIR" hg -R copy-pull pull
204 204 pulling from https://localhost:$HGPORT/
205 205 searching for changes
206 206 no changes found
207 207 $ P="$CERTSDIR" hg -R copy-pull pull --insecure
208 208 pulling from https://localhost:$HGPORT/
209 209 warning: connection security to localhost is disabled per current settings; communication is susceptible to eavesdropping and tampering
210 210 searching for changes
211 211 no changes found
212 212
213 213 empty cacert file
214 214
215 215 $ touch emptycafile
216 216
217 217 $ hg --config web.cacerts=emptycafile -R copy-pull pull
218 218 pulling from https://localhost:$HGPORT/
219 219 abort: error loading CA file emptycafile: * (glob)
220 220 (file is empty or malformed?)
221 221 [255]
222 222
223 223 cacert mismatch
224 224
225 225 $ hg -R copy-pull pull --config web.cacerts="$CERTSDIR/pub.pem" \
226 226 > https://$LOCALIP:$HGPORT/
227 227 pulling from https://*:$HGPORT/ (glob)
228 228 abort: $LOCALIP certificate error: certificate is for localhost (glob)
229 229 (set hostsecurity.$LOCALIP:certfingerprints=sha256:20:de:b3:ad:b4:cd:a5:42:f0:74:41:1c:a2:70:1e:da:6e:c0:5c:16:9e:e7:22:0f:f1:b7:e5:6e:e4:92:af:7e config setting or use --insecure to connect insecurely)
230 230 [150]
231 231 $ hg -R copy-pull pull --config web.cacerts="$CERTSDIR/pub.pem" \
232 232 > https://$LOCALIP:$HGPORT/ --insecure
233 233 pulling from https://*:$HGPORT/ (glob)
234 234 warning: connection security to $LOCALIP is disabled per current settings; communication is susceptible to eavesdropping and tampering (glob)
235 235 searching for changes
236 236 no changes found
237 237 $ hg -R copy-pull pull --config web.cacerts="$CERTSDIR/pub-other.pem"
238 238 pulling from https://localhost:$HGPORT/
239 239 (the full certificate chain may not be available locally; see "hg help debugssl") (windows !)
240 240 abort: error: *certificate verify failed* (glob)
241 241 [100]
242 242 $ hg -R copy-pull pull --config web.cacerts="$CERTSDIR/pub-other.pem" \
243 243 > --insecure
244 244 pulling from https://localhost:$HGPORT/
245 245 warning: connection security to localhost is disabled per current settings; communication is susceptible to eavesdropping and tampering
246 246 searching for changes
247 247 no changes found
248 248
249 249 Test server cert which isn't valid yet
250 250
251 251 $ hg serve -R test -p $HGPORT1 -d --pid-file=hg1.pid --certificate=server-not-yet.pem
252 252 $ cat hg1.pid >> $DAEMON_PIDS
253 253 $ hg -R copy-pull pull --config web.cacerts="$CERTSDIR/pub-not-yet.pem" \
254 254 > https://localhost:$HGPORT1/
255 255 pulling from https://localhost:$HGPORT1/
256 256 (the full certificate chain may not be available locally; see "hg help debugssl") (windows !)
257 257 abort: error: *certificate verify failed* (glob)
258 258 [100]
259 259
260 260 Test server cert which no longer is valid
261 261
262 262 $ hg serve -R test -p $HGPORT2 -d --pid-file=hg2.pid --certificate=server-expired.pem
263 263 $ cat hg2.pid >> $DAEMON_PIDS
264 264 $ hg -R copy-pull pull --config web.cacerts="$CERTSDIR/pub-expired.pem" \
265 265 > https://localhost:$HGPORT2/
266 266 pulling from https://localhost:$HGPORT2/
267 267 (the full certificate chain may not be available locally; see "hg help debugssl") (windows !)
268 268 abort: error: *certificate verify failed* (glob)
269 269 [100]
270 270
271 271 Setting ciphers to an invalid value aborts
272 272 $ P="$CERTSDIR" hg --config hostsecurity.ciphers=invalid -R copy-pull id https://localhost:$HGPORT/
273 273 abort: could not set ciphers: No cipher can be selected.
274 274 (change cipher string (invalid) in config)
275 275 [255]
276 276
277 277 $ P="$CERTSDIR" hg --config hostsecurity.localhost:ciphers=invalid -R copy-pull id https://localhost:$HGPORT/
278 278 abort: could not set ciphers: No cipher can be selected.
279 279 (change cipher string (invalid) in config)
280 280 [255]
281 281
282 282 Changing the cipher string works
283 283
284 284 $ P="$CERTSDIR" hg --config hostsecurity.ciphers=HIGH -R copy-pull id https://localhost:$HGPORT/
285 285 5fed3813f7f5
286 286
287 287 Fingerprints
288 288
289 289 - works without cacerts (hostfingerprints)
290 290 $ hg -R copy-pull id https://localhost:$HGPORT/ --insecure --config hostfingerprints.localhost=ec:d8:7c:d6:b3:86:d0:4f:c1:b8:b4:1c:9d:8f:5e:16:8e:ef:1c:03
291 291 (SHA-1 fingerprint for localhost found in legacy [hostfingerprints] section; if you trust this fingerprint, remove the old SHA-1 fingerprint from [hostfingerprints] and add the following entry to the new [hostsecurity] section: localhost:fingerprints=sha256:20:de:b3:ad:b4:cd:a5:42:f0:74:41:1c:a2:70:1e:da:6e:c0:5c:16:9e:e7:22:0f:f1:b7:e5:6e:e4:92:af:7e)
292 292 5fed3813f7f5
293 293
294 294 - works without cacerts (hostsecurity)
295 295 $ hg -R copy-pull id https://localhost:$HGPORT/ --config hostsecurity.localhost:fingerprints=sha1:ecd87cd6b386d04fc1b8b41c9d8f5e168eef1c03
296 296 5fed3813f7f5
297 297
298 298 $ hg -R copy-pull id https://localhost:$HGPORT/ --config hostsecurity.localhost:fingerprints=sha256:20:de:b3:ad:b4:cd:a5:42:f0:74:41:1c:a2:70:1e:da:6e:c0:5c:16:9e:e7:22:0f:f1:b7:e5:6e:e4:92:af:7e
299 299 5fed3813f7f5
300 300
301 301 - multiple fingerprints specified and first matches
302 302 $ hg --config 'hostfingerprints.localhost=ecd87cd6b386d04fc1b8b41c9d8f5e168eef1c03, deadbeefdeadbeefdeadbeefdeadbeefdeadbeef' -R copy-pull id https://localhost:$HGPORT/ --insecure
303 303 (SHA-1 fingerprint for localhost found in legacy [hostfingerprints] section; if you trust this fingerprint, remove the old SHA-1 fingerprint from [hostfingerprints] and add the following entry to the new [hostsecurity] section: localhost:fingerprints=sha256:20:de:b3:ad:b4:cd:a5:42:f0:74:41:1c:a2:70:1e:da:6e:c0:5c:16:9e:e7:22:0f:f1:b7:e5:6e:e4:92:af:7e)
304 304 5fed3813f7f5
305 305
306 306 $ hg --config 'hostsecurity.localhost:fingerprints=sha1:ecd87cd6b386d04fc1b8b41c9d8f5e168eef1c03, sha1:deadbeefdeadbeefdeadbeefdeadbeefdeadbeef' -R copy-pull id https://localhost:$HGPORT/
307 307 5fed3813f7f5
308 308
309 309 - multiple fingerprints specified and last matches
310 310 $ hg --config 'hostfingerprints.localhost=deadbeefdeadbeefdeadbeefdeadbeefdeadbeef, ecd87cd6b386d04fc1b8b41c9d8f5e168eef1c03' -R copy-pull id https://localhost:$HGPORT/ --insecure
311 311 (SHA-1 fingerprint for localhost found in legacy [hostfingerprints] section; if you trust this fingerprint, remove the old SHA-1 fingerprint from [hostfingerprints] and add the following entry to the new [hostsecurity] section: localhost:fingerprints=sha256:20:de:b3:ad:b4:cd:a5:42:f0:74:41:1c:a2:70:1e:da:6e:c0:5c:16:9e:e7:22:0f:f1:b7:e5:6e:e4:92:af:7e)
312 312 5fed3813f7f5
313 313
314 314 $ hg --config 'hostsecurity.localhost:fingerprints=sha1:deadbeefdeadbeefdeadbeefdeadbeefdeadbeef, sha1:ecd87cd6b386d04fc1b8b41c9d8f5e168eef1c03' -R copy-pull id https://localhost:$HGPORT/
315 315 5fed3813f7f5
316 316
317 317 - multiple fingerprints specified and none match
318 318
319 319 $ hg --config 'hostfingerprints.localhost=deadbeefdeadbeefdeadbeefdeadbeefdeadbeef, aeadbeefdeadbeefdeadbeefdeadbeefdeadbeef' -R copy-pull id https://localhost:$HGPORT/ --insecure
320 320 abort: certificate for localhost has unexpected fingerprint ec:d8:7c:d6:b3:86:d0:4f:c1:b8:b4:1c:9d:8f:5e:16:8e:ef:1c:03
321 321 (check hostfingerprint configuration)
322 322 [150]
323 323
324 324 $ hg --config 'hostsecurity.localhost:fingerprints=sha1:deadbeefdeadbeefdeadbeefdeadbeefdeadbeef, sha1:aeadbeefdeadbeefdeadbeefdeadbeefdeadbeef' -R copy-pull id https://localhost:$HGPORT/
325 325 abort: certificate for localhost has unexpected fingerprint sha1:ec:d8:7c:d6:b3:86:d0:4f:c1:b8:b4:1c:9d:8f:5e:16:8e:ef:1c:03
326 326 (check hostsecurity configuration)
327 327 [150]
328 328
329 329 - fails when cert doesn't match hostname (port is ignored)
330 330 $ hg -R copy-pull id https://localhost:$HGPORT1/ --config hostfingerprints.localhost=ecd87cd6b386d04fc1b8b41c9d8f5e168eef1c03
331 331 abort: certificate for localhost has unexpected fingerprint f4:2f:5a:0c:3e:52:5b:db:e7:24:a8:32:1d:18:97:6d:69:b5:87:84
332 332 (check hostfingerprint configuration)
333 333 [150]
334 334
335 335
336 336 - ignores that certificate doesn't match hostname
337 337 $ hg -R copy-pull id https://$LOCALIP:$HGPORT/ --config hostfingerprints.$LOCALIP=ecd87cd6b386d04fc1b8b41c9d8f5e168eef1c03
338 338 (SHA-1 fingerprint for $LOCALIP found in legacy [hostfingerprints] section; if you trust this fingerprint, remove the old SHA-1 fingerprint from [hostfingerprints] and add the following entry to the new [hostsecurity] section: $LOCALIP:fingerprints=sha256:20:de:b3:ad:b4:cd:a5:42:f0:74:41:1c:a2:70:1e:da:6e:c0:5c:16:9e:e7:22:0f:f1:b7:e5:6e:e4:92:af:7e)
339 339 5fed3813f7f5
340 340
341 341 Ports used by next test. Kill servers.
342 342
343 343 $ killdaemons.py hg0.pid
344 344 $ killdaemons.py hg1.pid
345 345 $ killdaemons.py hg2.pid
346 346
347 347 #if tls1.2
348 348 Start servers running supported TLS versions
349 349
350 350 $ cd test
351 351 $ hg serve -p $HGPORT -d --pid-file=../hg0.pid --certificate=$PRIV \
352 352 > --config devel.serverexactprotocol=tls1.0
353 353 $ cat ../hg0.pid >> $DAEMON_PIDS
354 354 $ hg serve -p $HGPORT1 -d --pid-file=../hg1.pid --certificate=$PRIV \
355 355 > --config devel.serverexactprotocol=tls1.1
356 356 $ cat ../hg1.pid >> $DAEMON_PIDS
357 357 $ hg serve -p $HGPORT2 -d --pid-file=../hg2.pid --certificate=$PRIV \
358 358 > --config devel.serverexactprotocol=tls1.2
359 359 $ cat ../hg2.pid >> $DAEMON_PIDS
360 360 $ cd ..
361 361
362 362 Clients talking same TLS versions work
363 363
364 $ P="$CERTSDIR" hg --config hostsecurity.minimumprotocol=tls1.0 id https://localhost:$HGPORT/
364 $ P="$CERTSDIR" hg --config hostsecurity.minimumprotocol=tls1.0 --config hostsecurity.ciphers=DEFAULT id https://localhost:$HGPORT/
365 365 5fed3813f7f5
366 $ P="$CERTSDIR" hg --config hostsecurity.minimumprotocol=tls1.1 id https://localhost:$HGPORT1/
366 $ P="$CERTSDIR" hg --config hostsecurity.minimumprotocol=tls1.1 --config hostsecurity.ciphers=DEFAULT id https://localhost:$HGPORT1/
367 367 5fed3813f7f5
368 368 $ P="$CERTSDIR" hg --config hostsecurity.minimumprotocol=tls1.2 id https://localhost:$HGPORT2/
369 369 5fed3813f7f5
370 370
371 371 Clients requiring newer TLS version than what server supports fail
372 372
373 373 $ P="$CERTSDIR" hg id https://localhost:$HGPORT/
374 374 (could not negotiate a common security protocol (tls1.1+) with localhost; the likely cause is Mercurial is configured to be more secure than the server can support)
375 375 (consider contacting the operator of this server and ask them to support modern TLS protocol versions; or, set hostsecurity.localhost:minimumprotocol=tls1.0 to allow use of legacy, less secure protocols when communicating with this server)
376 376 (see https://mercurial-scm.org/wiki/SecureConnections for more info)
377 377 abort: error: .*(unsupported protocol|wrong ssl version).* (re)
378 378 [100]
379 379
380 380 $ P="$CERTSDIR" hg --config hostsecurity.minimumprotocol=tls1.1 id https://localhost:$HGPORT/
381 381 (could not negotiate a common security protocol (tls1.1+) with localhost; the likely cause is Mercurial is configured to be more secure than the server can support)
382 382 (consider contacting the operator of this server and ask them to support modern TLS protocol versions; or, set hostsecurity.localhost:minimumprotocol=tls1.0 to allow use of legacy, less secure protocols when communicating with this server)
383 383 (see https://mercurial-scm.org/wiki/SecureConnections for more info)
384 384 abort: error: .*(unsupported protocol|wrong ssl version).* (re)
385 385 [100]
386 386 $ P="$CERTSDIR" hg --config hostsecurity.minimumprotocol=tls1.2 id https://localhost:$HGPORT/
387 387 (could not negotiate a common security protocol (tls1.2+) with localhost; the likely cause is Mercurial is configured to be more secure than the server can support)
388 388 (consider contacting the operator of this server and ask them to support modern TLS protocol versions; or, set hostsecurity.localhost:minimumprotocol=tls1.0 to allow use of legacy, less secure protocols when communicating with this server)
389 389 (see https://mercurial-scm.org/wiki/SecureConnections for more info)
390 390 abort: error: .*(unsupported protocol|wrong ssl version).* (re)
391 391 [100]
392 392 $ P="$CERTSDIR" hg --config hostsecurity.minimumprotocol=tls1.2 id https://localhost:$HGPORT1/
393 393 (could not negotiate a common security protocol (tls1.2+) with localhost; the likely cause is Mercurial is configured to be more secure than the server can support)
394 394 (consider contacting the operator of this server and ask them to support modern TLS protocol versions; or, set hostsecurity.localhost:minimumprotocol=tls1.0 to allow use of legacy, less secure protocols when communicating with this server)
395 395 (see https://mercurial-scm.org/wiki/SecureConnections for more info)
396 396 abort: error: .*(unsupported protocol|wrong ssl version).* (re)
397 397 [100]
398 398
399 399 --insecure will allow TLS 1.0 connections and override configs
400 400
401 401 $ hg --config hostsecurity.minimumprotocol=tls1.2 id --insecure https://localhost:$HGPORT1/
402 402 warning: connection security to localhost is disabled per current settings; communication is susceptible to eavesdropping and tampering
403 403 5fed3813f7f5
404 404
405 405 The per-host config option overrides the default
406 406
407 407 $ P="$CERTSDIR" hg id https://localhost:$HGPORT/ \
408 > --config hostsecurity.ciphers=DEFAULT \
408 409 > --config hostsecurity.minimumprotocol=tls1.2 \
409 410 > --config hostsecurity.localhost:minimumprotocol=tls1.0
410 411 5fed3813f7f5
411 412
412 413 The per-host config option by itself works
413 414
414 415 $ P="$CERTSDIR" hg id https://localhost:$HGPORT/ \
415 416 > --config hostsecurity.localhost:minimumprotocol=tls1.2
416 417 (could not negotiate a common security protocol (tls1.2+) with localhost; the likely cause is Mercurial is configured to be more secure than the server can support)
417 418 (consider contacting the operator of this server and ask them to support modern TLS protocol versions; or, set hostsecurity.localhost:minimumprotocol=tls1.0 to allow use of legacy, less secure protocols when communicating with this server)
418 419 (see https://mercurial-scm.org/wiki/SecureConnections for more info)
419 420 abort: error: .*(unsupported protocol|wrong ssl version).* (re)
420 421 [100]
421 422
422 423 .hg/hgrc file [hostsecurity] settings are applied to remote ui instances (issue5305)
423 424
424 425 $ cat >> copy-pull/.hg/hgrc << EOF
425 426 > [hostsecurity]
426 427 > localhost:minimumprotocol=tls1.2
427 428 > EOF
428 429 $ P="$CERTSDIR" hg -R copy-pull id https://localhost:$HGPORT/
429 430 (could not negotiate a common security protocol (tls1.2+) with localhost; the likely cause is Mercurial is configured to be more secure than the server can support)
430 431 (consider contacting the operator of this server and ask them to support modern TLS protocol versions; or, set hostsecurity.localhost:minimumprotocol=tls1.0 to allow use of legacy, less secure protocols when communicating with this server)
431 432 (see https://mercurial-scm.org/wiki/SecureConnections for more info)
432 433 abort: error: .*(unsupported protocol|wrong ssl version).* (re)
433 434 [100]
434 435
435 436 $ killdaemons.py hg0.pid
436 437 $ killdaemons.py hg1.pid
437 438 $ killdaemons.py hg2.pid
438 439 #endif
439 440
440 441 Prepare for connecting through proxy
441 442
442 443 $ hg serve -R test -p $HGPORT -d --pid-file=hg0.pid --certificate=$PRIV
443 444 $ cat hg0.pid >> $DAEMON_PIDS
444 445 $ hg serve -R test -p $HGPORT2 -d --pid-file=hg2.pid --certificate=server-expired.pem
445 446 $ cat hg2.pid >> $DAEMON_PIDS
446 447 tinyproxy.py doesn't fully detach, so killing it may result in extra output
447 448 from the shell. So don't kill it.
448 449 $ tinyproxy.py $HGPORT1 localhost >proxy.log </dev/null 2>&1 &
449 450 $ while [ ! -f proxy.pid ]; do sleep 0; done
450 451 $ cat proxy.pid >> $DAEMON_PIDS
451 452
452 453 $ echo "[http_proxy]" >> copy-pull/.hg/hgrc
453 454 $ echo "always=True" >> copy-pull/.hg/hgrc
454 455 $ echo "[hostfingerprints]" >> copy-pull/.hg/hgrc
455 456 $ echo "localhost =" >> copy-pull/.hg/hgrc
456 457
457 458 Test unvalidated https through proxy
458 459
459 460 $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull --insecure
460 461 pulling from https://localhost:$HGPORT/
461 462 warning: connection security to localhost is disabled per current settings; communication is susceptible to eavesdropping and tampering
462 463 searching for changes
463 464 no changes found
464 465
465 466 Test https with cacert and fingerprint through proxy
466 467
467 468 $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull \
468 469 > --config web.cacerts="$CERTSDIR/pub.pem"
469 470 pulling from https://localhost:$HGPORT/
470 471 searching for changes
471 472 no changes found
472 473 $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull https://localhost:$HGPORT/ --config hostfingerprints.localhost=ecd87cd6b386d04fc1b8b41c9d8f5e168eef1c03 --trace
473 474 pulling from https://*:$HGPORT/ (glob)
474 475 (SHA-1 fingerprint for localhost found in legacy [hostfingerprints] section; if you trust this fingerprint, remove the old SHA-1 fingerprint from [hostfingerprints] and add the following entry to the new [hostsecurity] section: localhost:fingerprints=sha256:20:de:b3:ad:b4:cd:a5:42:f0:74:41:1c:a2:70:1e:da:6e:c0:5c:16:9e:e7:22:0f:f1:b7:e5:6e:e4:92:af:7e)
475 476 searching for changes
476 477 no changes found
477 478
478 479 Test https with cert problems through proxy
479 480
480 481 $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull \
481 482 > --config web.cacerts="$CERTSDIR/pub-other.pem"
482 483 pulling from https://localhost:$HGPORT/
483 484 (the full certificate chain may not be available locally; see "hg help debugssl") (windows !)
484 485 abort: error: *certificate verify failed* (glob)
485 486 [100]
486 487 $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull \
487 488 > --config web.cacerts="$CERTSDIR/pub-expired.pem" https://localhost:$HGPORT2/
488 489 pulling from https://localhost:$HGPORT2/
489 490 (the full certificate chain may not be available locally; see "hg help debugssl") (windows !)
490 491 abort: error: *certificate verify failed* (glob)
491 492 [100]
492 493
493 494
494 495 $ killdaemons.py hg0.pid
495 496
496 497 $ cd test
497 498
498 499 Missing certificate file(s) are detected
499 500
500 501 $ hg serve -p $HGPORT --certificate=/missing/certificate \
501 502 > --config devel.servercafile=$PRIV --config devel.serverrequirecert=true
502 503 abort: referenced certificate file (*/missing/certificate) does not exist (glob)
503 504 [255]
504 505
505 506 $ hg serve -p $HGPORT --certificate=$PRIV \
506 507 > --config devel.servercafile=/missing/cafile --config devel.serverrequirecert=true
507 508 abort: referenced certificate file (*/missing/cafile) does not exist (glob)
508 509 [255]
509 510
510 511 Start hgweb that requires client certificates:
511 512
512 513 $ hg serve -p $HGPORT -d --pid-file=../hg0.pid --certificate=$PRIV \
513 514 > --config devel.servercafile=$PRIV --config devel.serverrequirecert=true
514 515 $ cat ../hg0.pid >> $DAEMON_PIDS
515 516 $ cd ..
516 517
517 518 without client certificate:
518 519
519 520 $ P="$CERTSDIR" hg id https://localhost:$HGPORT/
520 521 abort: error: .*(\$ECONNRESET\$|certificate required|handshake failure).* (re)
521 522 [100]
522 523
523 524 with client certificate:
524 525
525 526 $ cat << EOT >> $HGRCPATH
526 527 > [auth]
527 528 > l.prefix = localhost
528 529 > l.cert = $CERTSDIR/client-cert.pem
529 530 > l.key = $CERTSDIR/client-key.pem
530 531 > EOT
531 532
532 533 $ P="$CERTSDIR" hg id https://localhost:$HGPORT/ \
533 534 > --config auth.l.key="$CERTSDIR/client-key-decrypted.pem"
534 535 5fed3813f7f5
535 536
536 537 $ printf '1234\n' | env P="$CERTSDIR" hg id https://localhost:$HGPORT/ \
537 538 > --config ui.interactive=True --config ui.nontty=True
538 539 passphrase for */client-key.pem: 5fed3813f7f5 (glob)
539 540
540 541 $ env P="$CERTSDIR" hg id https://localhost:$HGPORT/
541 542 abort: error: * (glob)
542 543 [100]
543 544
544 545 Missing certficate and key files result in error
545 546
546 547 $ hg id https://localhost:$HGPORT/ --config auth.l.cert=/missing/cert
547 548 abort: certificate file (*/missing/cert) does not exist; cannot connect to localhost (glob)
548 549 (restore missing file or fix references in Mercurial config)
549 550 [255]
550 551
551 552 $ hg id https://localhost:$HGPORT/ --config auth.l.key=/missing/key
552 553 abort: certificate file (*/missing/key) does not exist; cannot connect to localhost (glob)
553 554 (restore missing file or fix references in Mercurial config)
554 555 [255]
General Comments 0
You need to be logged in to leave comments. Login now