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