[英]Got TLS error trying to find package ABC at https://pub.dartlang.org
I am using Linux Ubuntu 18.04.1 LTS .我正在使用Linux Ubuntu 18.04.1 LTS 。 I am creating a new Flutter project through git bash or terminal or from Visual Studio Code directly but gets an error which says:我正在通过 git bash 或终端或直接从 Visual Studio Code 创建一个新的Flutter项目,但收到一个错误消息:
Got TLS error trying to find package cupertino_icons at https://pub.dartlang.org尝试在https://pub.dartlang.org上查找包 cupertino_icons 时出现 TLS 错误
In Flutter Project's pubspec.yaml file I removed the line " cupertino_icons: ^0.1.2 " in an attempt to resolve the issue but gets the same error on another package:在 Flutter 项目的 pubspec.yaml 文件中,我删除了“ cupertino_icons: ^0.1.2 ”行以尝试解决该问题,但在另一个包上出现相同的错误:
Got TLS error trying to find package vector_math at https://pub.dartlang.org尝试在https://pub.dartlang.org上查找包 vector_math 时出现 TLS 错误
I've googled alot but couldn't find the right solution.我用谷歌搜索了很多,但找不到正确的解决方案。 Please do tell me the main cause of this issue and how to solve it?请告诉我这个问题的主要原因以及如何解决?
In my case it was due to network permissions in our organization.在我的情况下,这是由于我们组织中的网络权限。 I tried with some another network which has full access and my issue was resolved.我尝试了另一个具有完全访问权限的网络,我的问题得到了解决。
For those who find their way to this answer via Google, here's what worked for me.对于那些通过谷歌找到这个答案的人来说,这对我有用。 I am running Windows 10 x64 behind a corporate firewall (Zscaler), and my client uses a self-signed cert.我在公司防火墙 (Zscaler) 后面运行 Windows 10 x64,我的客户端使用自签名证书。 I eventually found this Github comment which described creating a system environment variable pointing to the self-signed cert.我最终找到了这个 Github 评论,它描述了创建一个指向自签名证书的系统环境变量。 Once I created the variable and restarted my command prompts, I was able to execute commands like flutter pub get
.创建变量并重新启动命令提示符后,我就可以执行flutter pub get
类的命令。
You might need to setup a self-signed certificate to make it work correctly by setting the following enviroment variables:您可能需要通过设置以下环境变量来设置自签名证书以使其正常工作:
On Linux:在 Linux 上:
export DART_VM_OPTIONS="--root-certs-file={path.to.certificate.file}" export DART_VM_OPTIONS="--root-certs-file={path.to.certificate.file}"
On Windows:在 Windows 上:
set https_proxy="--root-certs-file={path.to.certificate.file}"设置 https_proxy="--root-certs-file={path.to.certificate.file}"
And in case you behind a proxy , please, also set the proxy variables:如果您在代理后面,还请设置代理变量:
Linux: Linux:
export https_proxy="USERNAME:PASSWORD@hostname:port"导出 https_proxy="用户名:密码@主机名:端口"
Windows:视窗:
set https_proxy=USERNAME:PASSWORD@hostname:port设置 https_proxy=USERNAME:PASSWORD@hostname:port
It's working for me它对我有用
My example:我的例子:
1. Add dependency to pubspec.yaml file: 1. 在pubspec.yaml文件中添加依赖:
dependencies:依赖:
http:网址:
git:吉特:
url: git://github.com/dart-lang/http.git网址:git://github.com/dart-lang/http.git
http_parser: http_解析器:
dependency: transitive依赖:传递
description:描述:
name: http_parser名称:http_parser
url: " https://pub.dartlang.org "网址:“ https://pub.dartlang.org ”
source: hosted来源:托管
version: "3.1.3"版本:“3.1.3”
see more: Using Flutter Package查看更多: 使用 Flutter 包
我确实尝试了很多解决方案,但是当我使用 VPN 时它奏效了.. 在某些国家/地区似乎发生了这种情况。
I'm using ZScaler on Windows.我在 Windows 上使用 ZScaler。 Fortunately, I had the ZScaler root certificate sent over by someone from my corporate IT service desk team.幸运的是,我有公司 IT 服务台团队的某个人发送的 ZScaler 根证书。 The file name is ZscalerRootCA.cer And then, I used the following value for DART_VM_OPTIONS文件名是 ZscalerRootCA.cer 然后,我为 DART_VM_OPTIONS 使用了以下值
--root-certs-file=C:\\$PATH_TO_ZscalerRootCA.cer
我通过执行 Windows 更新故障排除解决了我的问题。
在虚拟机中,如果您的网络工作正常,则检查日期和时间。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.