Show More
@@ -1,268 +1,269 b'' | |||
|
1 | 1 | Proper https client requires the built-in ssl from Python 2.6. |
|
2 | 2 | |
|
3 | 3 | $ "$TESTDIR/hghave" ssl || exit 80 |
|
4 | 4 | |
|
5 | 5 | Certificates created with: |
|
6 | 6 | printf '.\n.\n.\n.\n.\nlocalhost\nhg@localhost\n' | \ |
|
7 | 7 | openssl req -newkey rsa:512 -keyout priv.pem -nodes -x509 -days 9000 -out pub.pem |
|
8 | 8 | Can be dumped with: |
|
9 | 9 | openssl x509 -in pub.pem -text |
|
10 | 10 | |
|
11 | 11 | $ cat << EOT > priv.pem |
|
12 | 12 | > -----BEGIN PRIVATE KEY----- |
|
13 | 13 | > MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEApjCWeYGrIa/Vo7LH |
|
14 | 14 | > aRF8ou0tbgHKE33Use/whCnKEUm34rDaXQd4lxxX6aDWg06n9tiVStAKTgQAHJY8 |
|
15 | 15 | > j/xgSwIDAQABAkBxHC6+Qlf0VJXGlb6NL16yEVVTQxqDS6hA9zqu6TZjrr0YMfzc |
|
16 | 16 | > EGNIiZGt7HCBL0zO+cPDg/LeCZc6HQhf0KrhAiEAzlJq4hWWzvguWFIJWSoBeBUG |
|
17 | 17 | > MF1ACazQO7PYE8M0qfECIQDONHHP0SKZzz/ZwBZcAveC5K61f/v9hONFwbeYulzR |
|
18 | 18 | > +wIgc9SvbtgB/5Yzpp//4ZAEnR7oh5SClCvyB+KSx52K3nECICbhQphhoXmI10wy |
|
19 | 19 | > aMTellaq0bpNMHFDziqH9RsqAHhjAiEAgYGxfzkftt5IUUn/iFK89aaIpyrpuaAh |
|
20 | 20 | > HY8gUVkVRVs= |
|
21 | 21 | > -----END PRIVATE KEY----- |
|
22 | 22 | > EOT |
|
23 | 23 | |
|
24 | 24 | $ cat << EOT > pub.pem |
|
25 | 25 | > -----BEGIN CERTIFICATE----- |
|
26 | 26 | > MIIBqzCCAVWgAwIBAgIJANAXFFyWjGnRMA0GCSqGSIb3DQEBBQUAMDExEjAQBgNV |
|
27 | 27 | > BAMMCWxvY2FsaG9zdDEbMBkGCSqGSIb3DQEJARYMaGdAbG9jYWxob3N0MB4XDTEw |
|
28 | 28 | > MTAxNDIwMzAxNFoXDTM1MDYwNTIwMzAxNFowMTESMBAGA1UEAwwJbG9jYWxob3N0 |
|
29 | 29 | > MRswGQYJKoZIhvcNAQkBFgxoZ0Bsb2NhbGhvc3QwXDANBgkqhkiG9w0BAQEFAANL |
|
30 | 30 | > ADBIAkEApjCWeYGrIa/Vo7LHaRF8ou0tbgHKE33Use/whCnKEUm34rDaXQd4lxxX |
|
31 | 31 | > 6aDWg06n9tiVStAKTgQAHJY8j/xgSwIDAQABo1AwTjAdBgNVHQ4EFgQUE6sA+amm |
|
32 | 32 | > r24dGX0kpjxOgO45hzQwHwYDVR0jBBgwFoAUE6sA+ammr24dGX0kpjxOgO45hzQw |
|
33 | 33 | > DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAANBAFArvQFiAZJgQczRsbYlG1xl |
|
34 | 34 | > t+truk37w5B3m3Ick1ntRcQrqs+hf0CO1q6Squ144geYaQ8CDirSR92fICELI1c= |
|
35 | 35 | > -----END CERTIFICATE----- |
|
36 | 36 | > EOT |
|
37 | 37 | $ cat priv.pem pub.pem >> server.pem |
|
38 | 38 | $ PRIV=`pwd`/server.pem |
|
39 | 39 | |
|
40 | 40 | $ cat << EOT > pub-other.pem |
|
41 | 41 | > -----BEGIN CERTIFICATE----- |
|
42 | 42 | > MIIBqzCCAVWgAwIBAgIJALwZS731c/ORMA0GCSqGSIb3DQEBBQUAMDExEjAQBgNV |
|
43 | 43 | > BAMMCWxvY2FsaG9zdDEbMBkGCSqGSIb3DQEJARYMaGdAbG9jYWxob3N0MB4XDTEw |
|
44 | 44 | > MTAxNDIwNDUxNloXDTM1MDYwNTIwNDUxNlowMTESMBAGA1UEAwwJbG9jYWxob3N0 |
|
45 | 45 | > MRswGQYJKoZIhvcNAQkBFgxoZ0Bsb2NhbGhvc3QwXDANBgkqhkiG9w0BAQEFAANL |
|
46 | 46 | > ADBIAkEAsxsapLbHrqqUKuQBxdpK4G3m2LjtyrTSdpzzzFlecxd5yhNP6AyWrufo |
|
47 | 47 | > K4VMGo2xlu9xOo88nDSUNSKPuD09MwIDAQABo1AwTjAdBgNVHQ4EFgQUoIB1iMhN |
|
48 | 48 | > y868rpQ2qk9dHnU6ebswHwYDVR0jBBgwFoAUoIB1iMhNy868rpQ2qk9dHnU6ebsw |
|
49 | 49 | > DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAANBAJ544f125CsE7J2t55PdFaF6 |
|
50 | 50 | > bBlNBb91FCywBgSjhBjf+GG3TNPwrPdc3yqeq+hzJiuInqbOBv9abmMyq8Wsoig= |
|
51 | 51 | > -----END CERTIFICATE----- |
|
52 | 52 | > EOT |
|
53 | 53 | |
|
54 | 54 | pub.pem patched with other notBefore / notAfter: |
|
55 | 55 | |
|
56 | 56 | $ cat << EOT > pub-not-yet.pem |
|
57 | 57 | > -----BEGIN CERTIFICATE----- |
|
58 | 58 | > MIIBqzCCAVWgAwIBAgIJANAXFFyWjGnRMA0GCSqGSIb3DQEBBQUAMDExEjAQBgNVBAMMCWxvY2Fs |
|
59 | 59 | > aG9zdDEbMBkGCSqGSIb3DQEJARYMaGdAbG9jYWxob3N0MB4XDTM1MDYwNTIwMzAxNFoXDTM1MDYw |
|
60 | 60 | > NTIwMzAxNFowMTESMBAGA1UEAwwJbG9jYWxob3N0MRswGQYJKoZIhvcNAQkBFgxoZ0Bsb2NhbGhv |
|
61 | 61 | > c3QwXDANBgkqhkiG9w0BAQEFAANLADBIAkEApjCWeYGrIa/Vo7LHaRF8ou0tbgHKE33Use/whCnK |
|
62 | 62 | > EUm34rDaXQd4lxxX6aDWg06n9tiVStAKTgQAHJY8j/xgSwIDAQABo1AwTjAdBgNVHQ4EFgQUE6sA |
|
63 | 63 | > +ammr24dGX0kpjxOgO45hzQwHwYDVR0jBBgwFoAUE6sA+ammr24dGX0kpjxOgO45hzQwDAYDVR0T |
|
64 | 64 | > BAUwAwEB/zANBgkqhkiG9w0BAQUFAANBAJXV41gWnkgC7jcpPpFRSUSZaxyzrXmD1CIqQf0WgVDb |
|
65 | 65 | > /12E0vR2DuZitgzUYtBaofM81aTtc0a2/YsrmqePGm0= |
|
66 | 66 | > -----END CERTIFICATE----- |
|
67 | 67 | > EOT |
|
68 | 68 | $ cat priv.pem pub-not-yet.pem > server-not-yet.pem |
|
69 | 69 | |
|
70 | 70 | $ cat << EOT > pub-expired.pem |
|
71 | 71 | > -----BEGIN CERTIFICATE----- |
|
72 | 72 | > MIIBqzCCAVWgAwIBAgIJANAXFFyWjGnRMA0GCSqGSIb3DQEBBQUAMDExEjAQBgNVBAMMCWxvY2Fs |
|
73 | 73 | > aG9zdDEbMBkGCSqGSIb3DQEJARYMaGdAbG9jYWxob3N0MB4XDTEwMTAxNDIwMzAxNFoXDTEwMTAx |
|
74 | 74 | > NDIwMzAxNFowMTESMBAGA1UEAwwJbG9jYWxob3N0MRswGQYJKoZIhvcNAQkBFgxoZ0Bsb2NhbGhv |
|
75 | 75 | > c3QwXDANBgkqhkiG9w0BAQEFAANLADBIAkEApjCWeYGrIa/Vo7LHaRF8ou0tbgHKE33Use/whCnK |
|
76 | 76 | > EUm34rDaXQd4lxxX6aDWg06n9tiVStAKTgQAHJY8j/xgSwIDAQABo1AwTjAdBgNVHQ4EFgQUE6sA |
|
77 | 77 | > +ammr24dGX0kpjxOgO45hzQwHwYDVR0jBBgwFoAUE6sA+ammr24dGX0kpjxOgO45hzQwDAYDVR0T |
|
78 | 78 | > BAUwAwEB/zANBgkqhkiG9w0BAQUFAANBAJfk57DTRf2nUbYaMSlVAARxMNbFGOjQhAUtY400GhKt |
|
79 | 79 | > 2uiKCNGKXVXD3AHWe13yHc5KttzbHQStE5Nm/DlWBWQ= |
|
80 | 80 | > -----END CERTIFICATE----- |
|
81 | 81 | > EOT |
|
82 | 82 | $ cat priv.pem pub-expired.pem > server-expired.pem |
|
83 | 83 | |
|
84 | 84 | $ hg init test |
|
85 | 85 | $ cd test |
|
86 | 86 | $ echo foo>foo |
|
87 | 87 | $ mkdir foo.d foo.d/bAr.hg.d foo.d/baR.d.hg |
|
88 | 88 | $ echo foo>foo.d/foo |
|
89 | 89 | $ echo bar>foo.d/bAr.hg.d/BaR |
|
90 | 90 | $ echo bar>foo.d/baR.d.hg/bAR |
|
91 | 91 | $ hg commit -A -m 1 |
|
92 | 92 | adding foo |
|
93 | 93 | adding foo.d/bAr.hg.d/BaR |
|
94 | 94 | adding foo.d/baR.d.hg/bAR |
|
95 | 95 | adding foo.d/foo |
|
96 | 96 | $ hg serve -p $HGPORT -d --pid-file=../hg0.pid --certificate=$PRIV |
|
97 | 97 | $ cat ../hg0.pid >> $DAEMON_PIDS |
|
98 | 98 | |
|
99 | 99 | Test server address cannot be reused |
|
100 | 100 | |
|
101 | 101 | $ hg serve -p $HGPORT --certificate=$PRIV 2>&1 |
|
102 | 102 | abort: cannot start server at ':$HGPORT': Address already in use |
|
103 | 103 | [255] |
|
104 | 104 | $ cd .. |
|
105 | 105 | |
|
106 | 106 | clone via pull |
|
107 | 107 | |
|
108 | 108 | $ hg clone https://localhost:$HGPORT/ copy-pull |
|
109 | 109 | warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) |
|
110 | 110 | requesting all changes |
|
111 | 111 | adding changesets |
|
112 | 112 | adding manifests |
|
113 | 113 | adding file changes |
|
114 | 114 | added 1 changesets with 4 changes to 4 files |
|
115 | 115 | warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) |
|
116 | 116 | updating to branch default |
|
117 | 117 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
118 | 118 | $ hg verify -R copy-pull |
|
119 | 119 | checking changesets |
|
120 | 120 | checking manifests |
|
121 | 121 | crosschecking files in changesets and manifests |
|
122 | 122 | checking files |
|
123 | 123 | 4 files, 1 changesets, 4 total revisions |
|
124 | 124 | $ cd test |
|
125 | 125 | $ echo bar > bar |
|
126 | 126 | $ hg commit -A -d '1 0' -m 2 |
|
127 | 127 | adding bar |
|
128 | 128 | $ cd .. |
|
129 | 129 | |
|
130 | 130 | pull without cacert |
|
131 | 131 | |
|
132 | 132 | $ cd copy-pull |
|
133 | 133 | $ echo '[hooks]' >> .hg/hgrc |
|
134 | 134 | $ echo "changegroup = python '$TESTDIR'/printenv.py changegroup" >> .hg/hgrc |
|
135 | 135 | $ hg pull |
|
136 | 136 | warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) |
|
137 | 137 | changegroup hook: HG_NODE=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_SOURCE=pull HG_URL=https://localhost:$HGPORT/ |
|
138 | 138 | pulling from https://localhost:$HGPORT/ |
|
139 | 139 | searching for changes |
|
140 | 140 | adding changesets |
|
141 | 141 | adding manifests |
|
142 | 142 | adding file changes |
|
143 | 143 | added 1 changesets with 1 changes to 1 files |
|
144 | 144 | warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) |
|
145 | 145 | (run 'hg update' to get a working copy) |
|
146 | 146 | $ cd .. |
|
147 | 147 | |
|
148 | 148 | cacert configured in local repo |
|
149 | 149 | |
|
150 | 150 | $ cp copy-pull/.hg/hgrc copy-pull/.hg/hgrc.bu |
|
151 | 151 | $ echo "[web]" >> copy-pull/.hg/hgrc |
|
152 | 152 | $ echo "cacerts=`pwd`/pub.pem" >> copy-pull/.hg/hgrc |
|
153 | 153 | $ hg -R copy-pull pull --traceback |
|
154 | 154 | pulling from https://localhost:$HGPORT/ |
|
155 | 155 | searching for changes |
|
156 | 156 | no changes found |
|
157 | 157 | $ mv copy-pull/.hg/hgrc.bu copy-pull/.hg/hgrc |
|
158 | 158 | |
|
159 | 159 | cacert configured globally, also testing expansion of environment |
|
160 | 160 | variables in the filename |
|
161 | 161 | |
|
162 | 162 | $ echo "[web]" >> $HGRCPATH |
|
163 | 163 | $ echo 'cacerts=$P/pub.pem' >> $HGRCPATH |
|
164 | 164 | $ P=`pwd` hg -R copy-pull pull |
|
165 | 165 | pulling from https://localhost:$HGPORT/ |
|
166 | 166 | searching for changes |
|
167 | 167 | no changes found |
|
168 | 168 | $ P=`pwd` hg -R copy-pull pull --insecure |
|
169 | 169 | warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) |
|
170 | 170 | pulling from https://localhost:$HGPORT/ |
|
171 | 171 | searching for changes |
|
172 | 172 | no changes found |
|
173 | 173 | |
|
174 | 174 | cacert mismatch |
|
175 | 175 | |
|
176 | 176 | $ hg -R copy-pull pull --config web.cacerts=pub.pem https://127.0.0.1:$HGPORT/ |
|
177 | 177 | abort: 127.0.0.1 certificate error: certificate is for localhost (use --insecure to connect insecurely) |
|
178 | 178 | [255] |
|
179 | 179 | $ hg -R copy-pull pull --config web.cacerts=pub.pem https://127.0.0.1:$HGPORT/ --insecure |
|
180 | 180 | warning: 127.0.0.1 certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) |
|
181 | 181 | pulling from https://127.0.0.1:$HGPORT/ |
|
182 | 182 | searching for changes |
|
183 | 183 | no changes found |
|
184 | 184 | $ hg -R copy-pull pull --config web.cacerts=pub-other.pem |
|
185 | 185 | abort: error: *:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (glob) |
|
186 | 186 | [255] |
|
187 | 187 | $ hg -R copy-pull pull --config web.cacerts=pub-other.pem --insecure |
|
188 | 188 | warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) |
|
189 | 189 | pulling from https://localhost:$HGPORT/ |
|
190 | 190 | searching for changes |
|
191 | 191 | no changes found |
|
192 | 192 | |
|
193 | 193 | Test server cert which isn't valid yet |
|
194 | 194 | |
|
195 | 195 | $ hg -R test serve -p $HGPORT1 -d --pid-file=hg1.pid --certificate=server-not-yet.pem |
|
196 | 196 | $ cat hg1.pid >> $DAEMON_PIDS |
|
197 | 197 | $ hg -R copy-pull pull --config web.cacerts=pub-not-yet.pem https://localhost:$HGPORT1/ |
|
198 | 198 | abort: error: *:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (glob) |
|
199 | 199 | [255] |
|
200 | 200 | |
|
201 | 201 | Test server cert which no longer is valid |
|
202 | 202 | |
|
203 | 203 | $ hg -R test serve -p $HGPORT2 -d --pid-file=hg2.pid --certificate=server-expired.pem |
|
204 | 204 | $ cat hg2.pid >> $DAEMON_PIDS |
|
205 | 205 | $ hg -R copy-pull pull --config web.cacerts=pub-expired.pem https://localhost:$HGPORT2/ |
|
206 | 206 | abort: error: *:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (glob) |
|
207 | 207 | [255] |
|
208 | 208 | |
|
209 | 209 | Fingerprints |
|
210 | 210 | |
|
211 | 211 | $ echo "[hostfingerprints]" >> copy-pull/.hg/hgrc |
|
212 | 212 | $ echo "localhost = 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca" >> copy-pull/.hg/hgrc |
|
213 | 213 | $ echo "127.0.0.1 = 914f1aff87249c09b6859b88b1906d30756491ca" >> copy-pull/.hg/hgrc |
|
214 | 214 | |
|
215 | 215 | - works without cacerts |
|
216 | 216 | $ hg -R copy-pull id https://localhost:$HGPORT/ --config web.cacerts= |
|
217 | 217 | 5fed3813f7f5 |
|
218 | 218 | |
|
219 | 219 | - fails when cert doesn't match hostname (port is ignored) |
|
220 | 220 | $ hg -R copy-pull id https://localhost:$HGPORT1/ |
|
221 | 221 | abort: invalid certificate for localhost with fingerprint 28:ff:71:bf:65:31:14:23:ad:62:92:b4:0e:31:99:18:fc:83:e3:9b |
|
222 | 222 | [255] |
|
223 | 223 | |
|
224 | 224 | - ignores that certificate doesn't match hostname |
|
225 | 225 | $ hg -R copy-pull id https://127.0.0.1:$HGPORT/ |
|
226 | 226 | 5fed3813f7f5 |
|
227 | 227 | |
|
228 | 228 | Prepare for connecting through proxy |
|
229 | 229 | |
|
230 | 230 | $ kill `cat hg1.pid` |
|
231 | 231 | $ sleep 1 |
|
232 | 232 | |
|
233 | 233 | $ ("$TESTDIR/tinyproxy.py" $HGPORT1 localhost >proxy.log 2>&1 </dev/null & |
|
234 | 234 | $ echo $! > proxy.pid) |
|
235 | 235 | $ cat proxy.pid >> $DAEMON_PIDS |
|
236 | 236 | $ sleep 2 |
|
237 | 237 | |
|
238 | 238 | $ echo "[http_proxy]" >> copy-pull/.hg/hgrc |
|
239 | 239 | $ echo "always=True" >> copy-pull/.hg/hgrc |
|
240 | 240 | $ echo "[hostfingerprints]" >> copy-pull/.hg/hgrc |
|
241 | 241 | $ echo "localhost =" >> copy-pull/.hg/hgrc |
|
242 | 242 | |
|
243 | 243 | Test unvalidated https through proxy |
|
244 | 244 | |
|
245 | 245 | $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull --insecure --traceback |
|
246 | warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) | |
|
246 | 247 | pulling from https://localhost:$HGPORT/ |
|
247 | 248 | searching for changes |
|
248 | 249 | no changes found |
|
249 | 250 | |
|
250 | 251 | Test https with cacert and fingerprint through proxy |
|
251 | 252 | |
|
252 | 253 | $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull --config web.cacerts=pub.pem |
|
253 | 254 | pulling from https://localhost:$HGPORT/ |
|
254 | 255 | searching for changes |
|
255 | 256 | no changes found |
|
256 | 257 | $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull https://127.0.0.1:$HGPORT/ |
|
257 | 258 | pulling from https://127.0.0.1:$HGPORT/ |
|
258 | 259 | searching for changes |
|
259 | 260 | no changes found |
|
260 | 261 | |
|
261 | 262 | Test https with cert problems through proxy |
|
262 | 263 | |
|
263 | 264 | $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull --config web.cacerts=pub-other.pem |
|
264 |
abort: error: |
|
|
265 | abort: error: *:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (glob) | |
|
265 | 266 | [255] |
|
266 | 267 | $ http_proxy=http://localhost:$HGPORT1/ hg -R copy-pull pull --config web.cacerts=pub-expired.pem https://localhost:$HGPORT2/ |
|
267 |
abort: error: |
|
|
268 | abort: error: *:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (glob) | |
|
268 | 269 | [255] |
General Comments 0
You need to be logged in to leave comments.
Login now