当前位置: 首页 > news >正文

go mod tidy 报错:x509: certificate signed by unknown authority 最佳实践

最近在docker中运行了一个ubuntu20的系统,在上面运行golang程序,使用go mod tidy后报错:

tls: failed to verify certificate: x509: certificate signed by unknown authority

如:

go: finding module for package google.golang.org/grpc/credentials/insecure
go: finding module for package github.com/shopspring/decimal
go: finding module for package github.com/stretchr/testify/assert
go: metag_media_server/app imports
	github.com/gin-gonic/gin: module github.com/gin-gonic/gin: Get "https://goproxy.cn/github.com/gin-gonic/gin/@v/list": tls: failed to verify certificate: x509: certificate signed by unknown authority
go: metag_media_server/app/config imports
	github.com/pkg/errors: module github.com/pkg/errors: Get "https://goproxy.cn/github.com/pkg/errors/@v/list": tls: failed to verify certificate: x509: certificate signed by unknown authority
go: metag_media_server/app/config imports
	github.com/spf13/viper: module github.com/spf13/viper: Get "https://goproxy.cn/github.com/spf13/viper/@v/list": tls: failed to verify certificate: x509: certificate signed by unknown authority
go: metag_media_server/app/controller imports
	github.com/axetroy/go-fs: module github.com/axetroy/go-fs: Get "https://goproxy.cn/github.com/axetroy/go-fs/@v/list": tls: failed to verify certificate: x509: certificate signed by unknown authority
go: metag_media_server/app/controller imports

出现这中情况一般都是自己安装全新的ubuntu系统,或者在docker中安装ubuntu镜像,跟我一样。

在网上找了很多资料,都没有解决。

这里提供两种最佳方案:

一:设置http的goproxy

export GOPROXY=http://goproxy.cn

或者

export GOPROXY=http://mirrors.aliyun.com/goproxy/

注意前缀不是https

二:重装ca-certificates

sudo apt-get install --reinstall ca-certificates
sudo apt-get update

之后就可以愉快的使用go mod tidy了

http://www.dtcms.com/a/1772.html

相关文章:

  • sentinel-dashboard-1.8.0.jar开机自启动脚本
  • 文件内容显示
  • 常用音频接口:TDM,PDM,I2S,PCM
  • .NET的键盘Hook管理类,用于禁用键盘输入和切换
  • 使用Python做一个微信机器人
  • Azure AD混合部署,通过 Intune 管理设备,实现条件访问
  • 8.6 枚举类型
  • Python15题day13
  • 爬虫为什么需要 HTTP 代理 IP?
  • 学习资源汇集
  • 找不到名称 “$“。是否需要安装 jQuery 的类型定义? 请尝试使用 `npm i --save-dev @types/jquery`。
  • PyCharm中使用pyqt5的方法2-2
  • Doris 2.0.1 Dockerfile制作
  • 【Java】数组的深浅拷贝问题(二维数组举例)(136)
  • SQL 如何提取多级分类目录
  • 从技能需求到就业前景,了解前端和后端开发的优缺点和个人选择
  • 数据结构——栈和队列
  • 【小余送书第一期】《数据要素安全流通》参与活动,即有机会中奖哦!!
  • 【蓝桥杯选拔赛真题62】Scratch判断小球 少儿编程scratch图形化编程 蓝桥杯选拔赛真题解析
  • Python中requirement 的使用
  • IntelliJ IDEA 左侧Commit栏不见了
  • 【面试题】有了Docker为啥还需要k8s?
  • MySQL之DML
  • 加速企业AI实施:成功策略和效率方法
  • 如何在Go中编写注释
  • 使用 FHE 实现加密大语言模型
  • SpringMVC 学习(七)JSON
  • 服务器补丁管理软件
  • elasticsearch 索引write.lock报错解决 —— 筑梦之路
  • 【JUC系列-08】深入理解CyclicBarrier底层原理和基本使用