##// END OF EJS Templates
tests: glob over ssl error...
Gregory Szorc -
r29635:dee24c87 stable
parent child Browse files
Show More
@@ -1,637 +1,637 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 Make server certificates:
6 6
7 7 $ CERTSDIR="$TESTDIR/sslcerts"
8 8 $ cat "$CERTSDIR/priv.pem" "$CERTSDIR/pub.pem" >> server.pem
9 9 $ PRIV=`pwd`/server.pem
10 10 $ cat "$CERTSDIR/priv.pem" "$CERTSDIR/pub-not-yet.pem" > server-not-yet.pem
11 11 $ cat "$CERTSDIR/priv.pem" "$CERTSDIR/pub-expired.pem" > server-expired.pem
12 12
13 13 $ hg init test
14 14 $ cd test
15 15 $ echo foo>foo
16 16 $ mkdir foo.d foo.d/bAr.hg.d foo.d/baR.d.hg
17 17 $ echo foo>foo.d/foo
18 18 $ echo bar>foo.d/bAr.hg.d/BaR
19 19 $ echo bar>foo.d/baR.d.hg/bAR
20 20 $ hg commit -A -m 1
21 21 adding foo
22 22 adding foo.d/bAr.hg.d/BaR
23 23 adding foo.d/baR.d.hg/bAR
24 24 adding foo.d/foo
25 25 $ hg serve -p $HGPORT -d --pid-file=../hg0.pid --certificate=$PRIV
26 26 $ cat ../hg0.pid >> $DAEMON_PIDS
27 27
28 28 cacert not found
29 29
30 30 $ hg in --config web.cacerts=no-such.pem https://localhost:$HGPORT/
31 31 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
32 32 abort: could not find web.cacerts: no-such.pem
33 33 [255]
34 34
35 35 Test server address cannot be reused
36 36
37 37 #if windows
38 38 $ hg serve -p $HGPORT --certificate=$PRIV 2>&1
39 39 abort: cannot start server at ':$HGPORT':
40 40 [255]
41 41 #else
42 42 $ hg serve -p $HGPORT --certificate=$PRIV 2>&1
43 43 abort: cannot start server at ':$HGPORT': Address already in use
44 44 [255]
45 45 #endif
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 sslcontext defaultcacerts 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 [255]
56 56 #endif
57 57
58 58 #if no-sslcontext defaultcacerts
59 59 $ hg clone https://localhost:$HGPORT/ copy-pull
60 60 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
61 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) (?)
62 62 abort: error: *certificate verify failed* (glob)
63 63 [255]
64 64 #endif
65 65
66 66 #if no-sslcontext windows
67 67 $ hg clone https://localhost:$HGPORT/ copy-pull
68 68 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info
69 69 (unable to load Windows CA certificates; see https://mercurial-scm.org/wiki/SecureConnections for how to configure Mercurial to avoid this message)
70 70 abort: error: *certificate verify failed* (glob)
71 71 [255]
72 72 #endif
73 73
74 74 #if no-sslcontext osx
75 75 $ hg clone https://localhost:$HGPORT/ copy-pull
76 76 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info
77 77 (unable to load CA certificates; see https://mercurial-scm.org/wiki/SecureConnections for how to configure Mercurial to avoid this message)
78 78 abort: localhost certificate error: no certificate received
79 79 (set hostsecurity.localhost: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)
80 80 [255]
81 81 #endif
82 82
83 83 #if defaultcacertsloaded
84 84 $ hg clone https://localhost:$HGPORT/ copy-pull
85 85 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
86 86 (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) (?)
87 87 abort: error: *certificate verify failed* (glob)
88 88 [255]
89 89 #endif
90 90
91 91 #if no-defaultcacerts
92 92 $ hg clone https://localhost:$HGPORT/ copy-pull
93 93 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
94 94 (unable to load * certificates; see https://mercurial-scm.org/wiki/SecureConnections for how to configure Mercurial to avoid this message) (glob) (?)
95 95 abort: localhost certificate error: no certificate received
96 96 (set hostsecurity.localhost: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)
97 97 [255]
98 98 #endif
99 99
100 100 Specifying a per-host certificate file that doesn't exist will abort
101 101
102 102 $ hg --config hostsecurity.localhost:verifycertsfile=/does/not/exist clone https://localhost:$HGPORT/
103 103 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
104 104 abort: path specified by hostsecurity.localhost:verifycertsfile does not exist: /does/not/exist
105 105 [255]
106 106
107 107 A malformed per-host certificate file will raise an error
108 108
109 109 $ echo baddata > badca.pem
110 110 #if sslcontext
111 111 $ hg --config hostsecurity.localhost:verifycertsfile=badca.pem clone https://localhost:$HGPORT/
112 112 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
113 113 abort: error loading CA file badca.pem: * (glob)
114 114 (file is empty or malformed?)
115 115 [255]
116 116 #else
117 117 $ hg --config hostsecurity.localhost:verifycertsfile=badca.pem clone https://localhost:$HGPORT/
118 118 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
119 119 abort: error: * (glob)
120 120 [255]
121 121 #endif
122 122
123 123 A per-host certificate mismatching the server will fail verification
124 124
125 125 (modern ssl is able to discern whether the loaded cert is a CA cert)
126 126 #if sslcontext
127 127 $ hg --config hostsecurity.localhost:verifycertsfile="$CERTSDIR/client-cert.pem" clone https://localhost:$HGPORT/
128 128 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
129 129 (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)
130 130 abort: error: *certificate verify failed* (glob)
131 131 [255]
132 132 #else
133 133 $ hg --config hostsecurity.localhost:verifycertsfile="$CERTSDIR/client-cert.pem" clone https://localhost:$HGPORT/
134 134 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
135 135 abort: error: *certificate verify failed* (glob)
136 136 [255]
137 137 #endif
138 138
139 139 A per-host certificate matching the server's cert will be accepted
140 140
141 141 $ hg --config hostsecurity.localhost:verifycertsfile="$CERTSDIR/pub.pem" clone -U https://localhost:$HGPORT/ perhostgood1
142 142 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
143 143 requesting all changes
144 144 adding changesets
145 145 adding manifests
146 146 adding file changes
147 147 added 1 changesets with 4 changes to 4 files
148 148
149 149 A per-host certificate with multiple certs and one matching will be accepted
150 150
151 151 $ cat "$CERTSDIR/client-cert.pem" "$CERTSDIR/pub.pem" > perhost.pem
152 152 $ hg --config hostsecurity.localhost:verifycertsfile=perhost.pem clone -U https://localhost:$HGPORT/ perhostgood2
153 153 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
154 154 requesting all changes
155 155 adding changesets
156 156 adding manifests
157 157 adding file changes
158 158 added 1 changesets with 4 changes to 4 files
159 159
160 160 Defining both per-host certificate and a fingerprint will print a warning
161 161
162 162 $ hg --config hostsecurity.localhost:verifycertsfile="$CERTSDIR/pub.pem" --config hostsecurity.localhost:fingerprints=sha1:ecd87cd6b386d04fc1b8b41c9d8f5e168eef1c03 clone -U https://localhost:$HGPORT/ caandfingerwarning
163 163 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
164 164 (hostsecurity.localhost:verifycertsfile ignored when host fingerprints defined; using host fingerprints for verification)
165 165 requesting all changes
166 166 adding changesets
167 167 adding manifests
168 168 adding file changes
169 169 added 1 changesets with 4 changes to 4 files
170 170
171 171 $ DISABLECACERTS="--config devel.disableloaddefaultcerts=true"
172 172
173 173 Inability to verify peer certificate will result in abort
174 174
175 175 $ hg clone https://localhost:$HGPORT/ copy-pull $DISABLECACERTS
176 176 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
177 177 abort: unable to verify security of localhost (no loaded CA certificates); refusing to connect
178 178 (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)
179 179 [255]
180 180
181 181 $ hg clone --insecure https://localhost:$HGPORT/ copy-pull
182 182 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
183 183 warning: connection security to localhost is disabled per current settings; communication is susceptible to eavesdropping and tampering
184 184 requesting all changes
185 185 adding changesets
186 186 adding manifests
187 187 adding file changes
188 188 added 1 changesets with 4 changes to 4 files
189 189 updating to branch default
190 190 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
191 191 $ hg verify -R copy-pull
192 192 checking changesets
193 193 checking manifests
194 194 crosschecking files in changesets and manifests
195 195 checking files
196 196 4 files, 1 changesets, 4 total revisions
197 197 $ cd test
198 198 $ echo bar > bar
199 199 $ hg commit -A -d '1 0' -m 2
200 200 adding bar
201 201 $ cd ..
202 202
203 203 pull without cacert
204 204
205 205 $ cd copy-pull
206 206 $ echo '[hooks]' >> .hg/hgrc
207 207 $ echo "changegroup = printenv.py changegroup" >> .hg/hgrc
208 208 $ hg pull $DISABLECACERTS
209 209 pulling from https://localhost:$HGPORT/
210 210 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
211 211 abort: unable to verify security of localhost (no loaded CA certificates); refusing to connect
212 212 (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)
213 213 [255]
214 214
215 215 $ hg pull --insecure
216 216 pulling from https://localhost:$HGPORT/
217 217 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
218 218 warning: connection security to localhost is disabled per current settings; communication is susceptible to eavesdropping and tampering
219 219 searching for changes
220 220 adding changesets
221 221 adding manifests
222 222 adding file changes
223 223 added 1 changesets with 1 changes to 1 files
224 224 changegroup hook: HG_NODE=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_NODE_LAST=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=https://localhost:$HGPORT/ (glob)
225 225 (run 'hg update' to get a working copy)
226 226 $ cd ..
227 227
228 228 cacert configured in local repo
229 229
230 230 $ cp copy-pull/.hg/hgrc copy-pull/.hg/hgrc.bu
231 231 $ echo "[web]" >> copy-pull/.hg/hgrc
232 232 $ echo "cacerts=$CERTSDIR/pub.pem" >> copy-pull/.hg/hgrc
233 233 $ hg -R copy-pull pull --traceback
234 234 pulling from https://localhost:$HGPORT/
235 235 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
236 236 searching for changes
237 237 no changes found
238 238 $ mv copy-pull/.hg/hgrc.bu copy-pull/.hg/hgrc
239 239
240 240 cacert configured globally, also testing expansion of environment
241 241 variables in the filename
242 242
243 243 $ echo "[web]" >> $HGRCPATH
244 244 $ echo 'cacerts=$P/pub.pem' >> $HGRCPATH
245 245 $ P="$CERTSDIR" hg -R copy-pull pull
246 246 pulling from https://localhost:$HGPORT/
247 247 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
248 248 searching for changes
249 249 no changes found
250 250 $ P="$CERTSDIR" hg -R copy-pull pull --insecure
251 251 pulling from https://localhost:$HGPORT/
252 252 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
253 253 warning: connection security to localhost is disabled per current settings; communication is susceptible to eavesdropping and tampering
254 254 searching for changes
255 255 no changes found
256 256
257 257 empty cacert file
258 258
259 259 $ touch emptycafile
260 260
261 261 #if sslcontext
262 262 $ hg --config web.cacerts=emptycafile -R copy-pull pull
263 263 pulling from https://localhost:$HGPORT/
264 264 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
265 265 abort: error loading CA file emptycafile: * (glob)
266 266 (file is empty or malformed?)
267 267 [255]
268 268 #else
269 269 $ hg --config web.cacerts=emptycafile -R copy-pull pull
270 270 pulling from https://localhost:$HGPORT/
271 271 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
272 272 abort: error: * (glob)
273 273 [255]
274 274 #endif
275 275
276 276 cacert mismatch
277 277
278 278 $ hg -R copy-pull pull --config web.cacerts="$CERTSDIR/pub.pem" \
279 279 > https://127.0.0.1:$HGPORT/
280 280 pulling from https://127.0.0.1:$HGPORT/ (glob)
281 281 warning: connecting to 127.0.0.1 using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
282 282 abort: 127.0.0.1 certificate error: certificate is for localhost (glob)
283 283 (set hostsecurity.127.0.0.1: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) (glob)
284 284 [255]
285 285 $ hg -R copy-pull pull --config web.cacerts="$CERTSDIR/pub.pem" \
286 286 > https://127.0.0.1:$HGPORT/ --insecure
287 287 pulling from https://127.0.0.1:$HGPORT/ (glob)
288 288 warning: connecting to 127.0.0.1 using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
289 289 warning: connection security to 127.0.0.1 is disabled per current settings; communication is susceptible to eavesdropping and tampering (glob)
290 290 searching for changes
291 291 no changes found
292 292 $ hg -R copy-pull pull --config web.cacerts="$CERTSDIR/pub-other.pem"
293 293 pulling from https://localhost:$HGPORT/
294 294 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
295 295 abort: error: *certificate verify failed* (glob)
296 296 [255]
297 297 $ hg -R copy-pull pull --config web.cacerts="$CERTSDIR/pub-other.pem" \
298 298 > --insecure
299 299 pulling from https://localhost:$HGPORT/
300 300 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
301 301 warning: connection security to localhost is disabled per current settings; communication is susceptible to eavesdropping and tampering
302 302 searching for changes
303 303 no changes found
304 304
305 305 Test server cert which isn't valid yet
306 306
307 307 $ hg serve -R test -p $HGPORT1 -d --pid-file=hg1.pid --certificate=server-not-yet.pem
308 308 $ cat hg1.pid >> $DAEMON_PIDS
309 309 $ hg -R copy-pull pull --config web.cacerts="$CERTSDIR/pub-not-yet.pem" \
310 310 > https://localhost:$HGPORT1/
311 311 pulling from https://localhost:$HGPORT1/
312 312 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
313 313 abort: error: *certificate verify failed* (glob)
314 314 [255]
315 315
316 316 Test server cert which no longer is valid
317 317
318 318 $ hg serve -R test -p $HGPORT2 -d --pid-file=hg2.pid --certificate=server-expired.pem
319 319 $ cat hg2.pid >> $DAEMON_PIDS
320 320 $ hg -R copy-pull pull --config web.cacerts="$CERTSDIR/pub-expired.pem" \
321 321 > https://localhost:$HGPORT2/
322 322 pulling from https://localhost:$HGPORT2/
323 323 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
324 324 abort: error: *certificate verify failed* (glob)
325 325 [255]
326 326
327 327 Disabling the TLS 1.0 warning works
328 328 $ hg -R copy-pull id https://localhost:$HGPORT/ \
329 329 > --config hostsecurity.localhost:fingerprints=sha1:ecd87cd6b386d04fc1b8b41c9d8f5e168eef1c03 \
330 330 > --config hostsecurity.disabletls10warning=true
331 331 5fed3813f7f5
332 332
333 333 #if no-sslcontext no-py27+
334 334 Setting ciphers doesn't work in Python 2.6
335 335 $ P="$CERTSDIR" hg --config hostsecurity.ciphers=HIGH -R copy-pull id https://localhost:$HGPORT/
336 336 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info
337 337 abort: setting ciphers in [hostsecurity] is not supported by this version of Python
338 338 (remove the config option or run Mercurial with a modern Python version (preferred))
339 339 [255]
340 340 #endif
341 341
342 342 Setting ciphers works in Python 2.7+ but the error message is different on
343 343 legacy ssl. We test legacy once and do more feature checking on modern
344 344 configs.
345 345
346 346 #if py27+ no-sslcontext
347 347 $ P="$CERTSDIR" hg --config hostsecurity.ciphers=invalid -R copy-pull id https://localhost:$HGPORT/
348 348 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info
349 349 abort: *No cipher can be selected. (glob)
350 350 [255]
351 351
352 352 $ P="$CERTSDIR" hg --config hostsecurity.ciphers=HIGH -R copy-pull id https://localhost:$HGPORT/
353 353 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info
354 354 5fed3813f7f5
355 355 #endif
356 356
357 357 #if sslcontext
358 358 Setting ciphers to an invalid value aborts
359 359 $ P="$CERTSDIR" hg --config hostsecurity.ciphers=invalid -R copy-pull id https://localhost:$HGPORT/
360 360 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
361 361 abort: could not set ciphers: No cipher can be selected.
362 362 (change cipher string (invalid) in config)
363 363 [255]
364 364
365 365 $ P="$CERTSDIR" hg --config hostsecurity.localhost:ciphers=invalid -R copy-pull id https://localhost:$HGPORT/
366 366 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
367 367 abort: could not set ciphers: No cipher can be selected.
368 368 (change cipher string (invalid) in config)
369 369 [255]
370 370
371 371 Changing the cipher string works
372 372
373 373 $ P="$CERTSDIR" hg --config hostsecurity.ciphers=HIGH -R copy-pull id https://localhost:$HGPORT/
374 374 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
375 375 5fed3813f7f5
376 376 #endif
377 377
378 378 Fingerprints
379 379
380 380 - works without cacerts (hostkeyfingerprints)
381 381 $ 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
382 382 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
383 383 5fed3813f7f5
384 384
385 385 - works without cacerts (hostsecurity)
386 386 $ hg -R copy-pull id https://localhost:$HGPORT/ --config hostsecurity.localhost:fingerprints=sha1:ecd87cd6b386d04fc1b8b41c9d8f5e168eef1c03
387 387 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
388 388 5fed3813f7f5
389 389
390 390 $ 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
391 391 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
392 392 5fed3813f7f5
393 393
394 394 - multiple fingerprints specified and first matches
395 395 $ hg --config 'hostfingerprints.localhost=ecd87cd6b386d04fc1b8b41c9d8f5e168eef1c03, deadbeefdeadbeefdeadbeefdeadbeefdeadbeef' -R copy-pull id https://localhost:$HGPORT/ --insecure
396 396 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
397 397 5fed3813f7f5
398 398
399 399 $ hg --config 'hostsecurity.localhost:fingerprints=sha1:ecd87cd6b386d04fc1b8b41c9d8f5e168eef1c03, sha1:deadbeefdeadbeefdeadbeefdeadbeefdeadbeef' -R copy-pull id https://localhost:$HGPORT/
400 400 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
401 401 5fed3813f7f5
402 402
403 403 - multiple fingerprints specified and last matches
404 404 $ hg --config 'hostfingerprints.localhost=deadbeefdeadbeefdeadbeefdeadbeefdeadbeef, ecd87cd6b386d04fc1b8b41c9d8f5e168eef1c03' -R copy-pull id https://localhost:$HGPORT/ --insecure
405 405 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
406 406 5fed3813f7f5
407 407
408 408 $ hg --config 'hostsecurity.localhost:fingerprints=sha1:deadbeefdeadbeefdeadbeefdeadbeefdeadbeef, sha1:ecd87cd6b386d04fc1b8b41c9d8f5e168eef1c03' -R copy-pull id https://localhost:$HGPORT/
409 409 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
410 410 5fed3813f7f5
411 411
412 412 - multiple fingerprints specified and none match
413 413
414 414 $ hg --config 'hostfingerprints.localhost=deadbeefdeadbeefdeadbeefdeadbeefdeadbeef, aeadbeefdeadbeefdeadbeefdeadbeefdeadbeef' -R copy-pull id https://localhost:$HGPORT/ --insecure
415 415 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
416 416 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
417 417 (check hostfingerprint configuration)
418 418 [255]
419 419
420 420 $ hg --config 'hostsecurity.localhost:fingerprints=sha1:deadbeefdeadbeefdeadbeefdeadbeefdeadbeef, sha1:aeadbeefdeadbeefdeadbeefdeadbeefdeadbeef' -R copy-pull id https://localhost:$HGPORT/
421 421 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
422 422 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
423 423 (check hostsecurity configuration)
424 424 [255]
425 425
426 426 - fails when cert doesn't match hostname (port is ignored)
427 427 $ hg -R copy-pull id https://localhost:$HGPORT1/ --config hostfingerprints.localhost=ecd87cd6b386d04fc1b8b41c9d8f5e168eef1c03
428 428 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
429 429 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
430 430 (check hostfingerprint configuration)
431 431 [255]
432 432
433 433
434 434 - ignores that certificate doesn't match hostname
435 435 $ hg -R copy-pull id https://127.0.0.1:$HGPORT/ --config hostfingerprints.127.0.0.1=ecd87cd6b386d04fc1b8b41c9d8f5e168eef1c03
436 436 warning: connecting to 127.0.0.1 using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
437 437 5fed3813f7f5
438 438
439 439 Ports used by next test. Kill servers.
440 440
441 441 $ killdaemons.py hg0.pid
442 442 $ killdaemons.py hg1.pid
443 443 $ killdaemons.py hg2.pid
444 444
445 445 #if sslcontext tls1.2
446 446 Start servers running supported TLS versions
447 447
448 448 $ cd test
449 449 $ hg serve -p $HGPORT -d --pid-file=../hg0.pid --certificate=$PRIV \
450 450 > --config devel.serverexactprotocol=tls1.0
451 451 $ cat ../hg0.pid >> $DAEMON_PIDS
452 452 $ hg serve -p $HGPORT1 -d --pid-file=../hg1.pid --certificate=$PRIV \
453 453 > --config devel.serverexactprotocol=tls1.1
454 454 $ cat ../hg1.pid >> $DAEMON_PIDS
455 455 $ hg serve -p $HGPORT2 -d --pid-file=../hg2.pid --certificate=$PRIV \
456 456 > --config devel.serverexactprotocol=tls1.2
457 457 $ cat ../hg2.pid >> $DAEMON_PIDS
458 458 $ cd ..
459 459
460 460 Clients talking same TLS versions work
461 461
462 462 $ P="$CERTSDIR" hg --config hostsecurity.minimumprotocol=tls1.0 id https://localhost:$HGPORT/
463 463 5fed3813f7f5
464 464 $ P="$CERTSDIR" hg --config hostsecurity.minimumprotocol=tls1.1 id https://localhost:$HGPORT1/
465 465 5fed3813f7f5
466 466 $ P="$CERTSDIR" hg --config hostsecurity.minimumprotocol=tls1.2 id https://localhost:$HGPORT2/
467 467 5fed3813f7f5
468 468
469 469 Clients requiring newer TLS version than what server supports fail
470 470
471 471 $ P="$CERTSDIR" hg id https://localhost:$HGPORT/
472 472 (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)
473 473 (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)
474 474 (see https://mercurial-scm.org/wiki/SecureConnections for more info)
475 475 abort: error: *unsupported protocol* (glob)
476 476 [255]
477 477
478 478 $ P="$CERTSDIR" hg --config hostsecurity.minimumprotocol=tls1.1 id https://localhost:$HGPORT/
479 479 (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)
480 480 (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)
481 481 (see https://mercurial-scm.org/wiki/SecureConnections for more info)
482 482 abort: error: *unsupported protocol* (glob)
483 483 [255]
484 484 $ P="$CERTSDIR" hg --config hostsecurity.minimumprotocol=tls1.2 id https://localhost:$HGPORT/
485 485 (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)
486 486 (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)
487 487 (see https://mercurial-scm.org/wiki/SecureConnections for more info)
488 488 abort: error: *unsupported protocol* (glob)
489 489 [255]
490 490 $ P="$CERTSDIR" hg --config hostsecurity.minimumprotocol=tls1.2 id https://localhost:$HGPORT1/
491 491 (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)
492 492 (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)
493 493 (see https://mercurial-scm.org/wiki/SecureConnections for more info)
494 494 abort: error: *unsupported protocol* (glob)
495 495 [255]
496 496
497 497 --insecure will allow TLS 1.0 connections and override configs
498 498
499 499 $ hg --config hostsecurity.minimumprotocol=tls1.2 id --insecure https://localhost:$HGPORT1/
500 500 warning: connection security to localhost is disabled per current settings; communication is susceptible to eavesdropping and tampering
501 501 5fed3813f7f5
502 502
503 503 The per-host config option overrides the default
504 504
505 505 $ P="$CERTSDIR" hg id https://localhost:$HGPORT/ \
506 506 > --config hostsecurity.minimumprotocol=tls1.2 \
507 507 > --config hostsecurity.localhost:minimumprotocol=tls1.0
508 508 5fed3813f7f5
509 509
510 510 The per-host config option by itself works
511 511
512 512 $ P="$CERTSDIR" hg id https://localhost:$HGPORT/ \
513 513 > --config hostsecurity.localhost:minimumprotocol=tls1.2
514 514 (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)
515 515 (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)
516 516 (see https://mercurial-scm.org/wiki/SecureConnections for more info)
517 517 abort: error: *unsupported protocol* (glob)
518 518 [255]
519 519
520 520 .hg/hgrc file [hostsecurity] settings are applied to remote ui instances (issue5305)
521 521
522 522 $ cat >> copy-pull/.hg/hgrc << EOF
523 523 > [hostsecurity]
524 524 > localhost:minimumprotocol=tls1.2
525 525 > EOF
526 526 $ P="$CERTSDIR" hg -R copy-pull id https://localhost:$HGPORT/
527 527 (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)
528 528 (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)
529 529 (see https://mercurial-scm.org/wiki/SecureConnections for more info)
530 abort: error: [SSL: UNSUPPORTED_PROTOCOL] unsupported protocol (_ssl.c:590)
530 abort: error: *unsupported protocol* (glob)
531 531 [255]
532 532
533 533 $ killdaemons.py hg0.pid
534 534 $ killdaemons.py hg1.pid
535 535 $ killdaemons.py hg2.pid
536 536 #endif
537 537
538 538 Prepare for connecting through proxy
539 539
540 540 $ hg serve -R test -p $HGPORT -d --pid-file=hg0.pid --certificate=$PRIV
541 541 $ cat hg0.pid >> $DAEMON_PIDS
542 542 $ hg serve -R test -p $HGPORT2 -d --pid-file=hg2.pid --certificate=server-expired.pem
543 543 $ cat hg2.pid >> $DAEMON_PIDS
544 544 tinyproxy.py doesn't fully detach, so killing it may result in extra output
545 545 from the shell. So don't kill it.
546 546 $ tinyproxy.py $HGPORT1 localhost >proxy.log </dev/null 2>&1 &
547 547 $ while [ ! -f proxy.pid ]; do sleep 0; done
548 548 $ cat proxy.pid >> $DAEMON_PIDS
549 549
550 550 $ echo "[http_proxy]" >> copy-pull/.hg/hgrc
551 551 $ echo "always=True" >> copy-pull/.hg/hgrc
552 552 $ echo "[hostfingerprints]" >> copy-pull/.hg/hgrc
553 553 $ echo "localhost =" >> copy-pull/.hg/hgrc
554 554
555 555 Test unvalidated https through proxy
556 556
557 557 $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull --insecure --traceback
558 558 pulling from https://localhost:$HGPORT/
559 559 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
560 560 warning: connection security to localhost is disabled per current settings; communication is susceptible to eavesdropping and tampering
561 561 searching for changes
562 562 no changes found
563 563
564 564 Test https with cacert and fingerprint through proxy
565 565
566 566 $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull \
567 567 > --config web.cacerts="$CERTSDIR/pub.pem"
568 568 pulling from https://localhost:$HGPORT/
569 569 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
570 570 searching for changes
571 571 no changes found
572 572 $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull https://127.0.0.1:$HGPORT/ --config hostfingerprints.127.0.0.1=ecd87cd6b386d04fc1b8b41c9d8f5e168eef1c03
573 573 pulling from https://127.0.0.1:$HGPORT/ (glob)
574 574 warning: connecting to 127.0.0.1 using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
575 575 searching for changes
576 576 no changes found
577 577
578 578 Test https with cert problems through proxy
579 579
580 580 $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull \
581 581 > --config web.cacerts="$CERTSDIR/pub-other.pem"
582 582 pulling from https://localhost:$HGPORT/
583 583 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
584 584 abort: error: *certificate verify failed* (glob)
585 585 [255]
586 586 $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull \
587 587 > --config web.cacerts="$CERTSDIR/pub-expired.pem" https://localhost:$HGPORT2/
588 588 pulling from https://localhost:$HGPORT2/
589 589 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
590 590 abort: error: *certificate verify failed* (glob)
591 591 [255]
592 592
593 593
594 594 $ killdaemons.py hg0.pid
595 595
596 596 #if sslcontext
597 597
598 598 Start hgweb that requires client certificates:
599 599
600 600 $ cd test
601 601 $ hg serve -p $HGPORT -d --pid-file=../hg0.pid --certificate=$PRIV \
602 602 > --config devel.servercafile=$PRIV --config devel.serverrequirecert=true
603 603 $ cat ../hg0.pid >> $DAEMON_PIDS
604 604 $ cd ..
605 605
606 606 without client certificate:
607 607
608 608 $ P="$CERTSDIR" hg id https://localhost:$HGPORT/
609 609 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
610 610 abort: error: *handshake failure* (glob)
611 611 [255]
612 612
613 613 with client certificate:
614 614
615 615 $ cat << EOT >> $HGRCPATH
616 616 > [auth]
617 617 > l.prefix = localhost
618 618 > l.cert = $CERTSDIR/client-cert.pem
619 619 > l.key = $CERTSDIR/client-key.pem
620 620 > EOT
621 621
622 622 $ P="$CERTSDIR" hg id https://localhost:$HGPORT/ \
623 623 > --config auth.l.key="$CERTSDIR/client-key-decrypted.pem"
624 624 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
625 625 5fed3813f7f5
626 626
627 627 $ printf '1234\n' | env P="$CERTSDIR" hg id https://localhost:$HGPORT/ \
628 628 > --config ui.interactive=True --config ui.nontty=True
629 629 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
630 630 passphrase for */client-key.pem: 5fed3813f7f5 (glob)
631 631
632 632 $ env P="$CERTSDIR" hg id https://localhost:$HGPORT/
633 633 warning: connecting to localhost using legacy security technology (TLS 1.0); see https://mercurial-scm.org/wiki/SecureConnections for more info (?)
634 634 abort: error: * (glob)
635 635 [255]
636 636
637 637 #endif
General Comments 0
You need to be logged in to leave comments. Login now