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