在使用Bazel下载github的一些packages时遇到如下报错:
ERROR: An error occurred during the fetch of repository 'bazel_skylib':
java.io.IOException: Error downloading [https://github.com/bazelbuild/bazel-skylib/releases/download/0.9.0/bazel_skylib-0.9.0.tar.gz] to /root/.cache/bazel/_bazel_root/4884d566396e9b67b62185751879ad14/external/bazel_skylib/bazel_skylib-0.9.0.tar.gz: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
原因是sun的https下载对安全要求比较严格,使用不是他信任的certificates下载会遇到问题。就查了一下, 是我使用的公司服务器(CA颁发者)对github的CA证书是不被认可的,更换到其他服务器(即换个网络)就可以了。或者如果不想更换网络并且项目需要下载的包文件比较少,可以将这些包wget your_package_address --no-check-certificate 下载到本地,然后更改WORKSPACE文件:
http_archive(
name = "com_github_glog_glog",
strip_prefix = "glog-0a2e5931bd5ff22fd3bf8999eb8ce776f159cda6",
sha256 = "58c9b3b6aaa4dd8b836c0fd8f65d0f941441fb95e27212c5eeb9979cfd3592ab",
urls = [
"file:///user_local_path/some_path/package_name.zip",
],
)
PS:
查看CA证书的签名可以通过使用浏览访问该https网址,点击网址右侧小锁头,里面查看CA详情,详情里面会有网站证书的信息。