diff options
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/fetch2/wget.py | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/bitbake/lib/bb/fetch2/wget.py b/bitbake/lib/bb/fetch2/wget.py index 784df70c9f..988ea74d26 100644 --- a/bitbake/lib/bb/fetch2/wget.py +++ b/bitbake/lib/bb/fetch2/wget.py | |||
@@ -282,19 +282,40 @@ class Wget(FetchMethod): | |||
282 | newreq = urllib.request.HTTPRedirectHandler.redirect_request(self, req, fp, code, msg, headers, newurl) | 282 | newreq = urllib.request.HTTPRedirectHandler.redirect_request(self, req, fp, code, msg, headers, newurl) |
283 | newreq.get_method = req.get_method | 283 | newreq.get_method = req.get_method |
284 | return newreq | 284 | return newreq |
285 | exported_proxies = export_proxies(d) | 285 | |
286 | 286 | # We need to update the environment here as both the proxy and HTTPS | |
287 | handlers = [FixedHTTPRedirectHandler, HTTPMethodFallback] | 287 | # handlers need variables set. The proxy needs http_proxy and friends to |
288 | if exported_proxies: | 288 | # be set, and HTTPSHandler ends up calling into openssl to load the |
289 | handlers.append(urllib.request.ProxyHandler()) | 289 | # certificates. In buildtools configurations this will be looking at the |
290 | handlers.append(CacheHTTPHandler()) | 290 | # wrong place for certificates by default: we set SSL_CERT_FILE to the |
291 | # Since Python 2.7.9 ssl cert validation is enabled by default | 291 | # right location in the buildtools environment script but as BitBake |
292 | # see PEP-0476, this causes verification errors on some https servers | 292 | # prunes prunes the environment this is lost. When binaries are executed |
293 | # so disable by default. | 293 | # runfetchcmd ensures these values are in the environment, but this is |
294 | import ssl | 294 | # pure Python so we need to update the environment. |
295 | if hasattr(ssl, '_create_unverified_context'): | 295 | # |
296 | handlers.append(urllib.request.HTTPSHandler(context=ssl._create_unverified_context())) | 296 | # Avoid tramping the environment too much by using bb.utils.environment |
297 | opener = urllib.request.build_opener(*handlers) | 297 | # to scope the changes to the build_opener request, which is when the |
298 | # environment lookups happen. | ||
299 | newenv = {} | ||
300 | for name in bb.fetch2.FETCH_EXPORT_VARS: | ||
301 | value = d.getVar(name) | ||
302 | if not value: | ||
303 | origenv = d.getVar("BB_ORIGENV") | ||
304 | if origenv: | ||
305 | value = origenv.getVar(name) | ||
306 | if value: | ||
307 | newenv[name] = value | ||
308 | |||
309 | with bb.utils.environment(**newenv): | ||
310 | import ssl | ||
311 | |||
312 | context = ssl._create_unverified_context() | ||
313 | handlers = [FixedHTTPRedirectHandler, | ||
314 | HTTPMethodFallback, | ||
315 | urllib.request.ProxyHandler(), | ||
316 | CacheHTTPHandler(), | ||
317 | urllib.request.HTTPSHandler(context=context)] | ||
318 | opener = urllib.request.build_opener(*handlers) | ||
298 | 319 | ||
299 | try: | 320 | try: |
300 | uri = ud.url.split(";")[0] | 321 | uri = ud.url.split(";")[0] |