简体   繁体   English

尝试在 https://pub.dartlang.org 上查找包 ABC 时出现 TLS 错误

[英]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

  1. When run cmd: flutter packages get.运行cmd时:flutter包得到。 A error will appear at "http_parser" package “http_parser”包会出现错误
  2. Now, download "http_parser" package from https://pub.dev/ (Version tab -> archive) and extract it to (if it not existed) %FLUTTER_HOME%.pub-cache\\hosted\\pub.dartlang.org现在,从https://pub.dev/ (版本选项卡 -> 存档)下载“http_parser”包并将其解压缩到(如果它不存在)%FLUTTER_HOME%.pub-cache\\hosted\\pub.dartlang.org
  3. Add new line in pubspec.lock file (at root folder of project)pubspec.lock文件中添加新行(在项目的根文件夹中)

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”

  1. Finally, run cmd: flutter packages get again!最后,运行cmd: flutter包再次获取

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.

相关问题 无法解析 URL“https://pub.dartlang.org”。错误 (69):无法“发布升级”flutter 工具。 五秒后重试……(还剩 10 次尝试) - Could not resolve URL "https://pub.dartlang.org".Error (69): Unable to 'pub upgrade' flutter tool. Retrying in five seconds… (10 tries left) 无法解析 URL“https://pub.dartlang.org”。 错误 (69):无法“发布升级”flutter 工具。 五秒后重试...(还剩 9 次尝试) - Could not resolve URL "https://pub.dartlang.org". Error (69): Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (9 tries left) 我已经安装了 nodejs,但尝试在终端中运行代码显示错误“找不到模块” - I've got nodejs installed but trying to run code in the terminal shows error "can't find module" 无法导入 google.golang.org/grpc(找不到 package “google.golang.org/grpc” - could not import google.golang.org/grpc (cannot find package "google.golang.org/grpc" 为什么即使我在Visual Studio Code中将它们导入,也会出现丢失的包错误 - Why I got the missing package error even though I imported them in Visual Studio Code 为什么在尝试从 org 检索源时出现套接字挂断错误? - why socket hang up error comes while trying to retrieve source from org? `使用VS代码时找不到包“appengine”错误 - `cannot find package “appengine” error` when using VS code 尝试通过 vs 代码将我的组织连接到 salesforce cli,得到错误:REST API 未为此组织启用 - Trying to connect my org to salesforce cli via vs code, gettinbg the error : The REST API is not enabled for this Organization Snap 在尝试运行“代码”(VSCode) 或任何其他 snap 时抛出错误 package - Snap throws error when trying to run 'code' (VSCode) or any other snap package 错误扩展入口点丢失,而我正在尝试 package 使用 vsce 开发的 vscode 扩展 - ERROR Extension entrypoint(s) missing while I'm trying to package a developed vscode extension with vsce
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM