当前位置: 首页 > 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了

相关文章:

  • 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 的使用
  • 俄罗斯期望乌克兰在停火期间采取行动缓和局势
  • 巴菲特第60次股东大会开场点赞库克:他为伯克希尔赚的钱比我还多
  • 贵州赤水一处岩体崩塌致4车受损,连夜抢修后已恢复通车
  • 9米长林肯车开进“皖南川藏线”致拥堵数小时,车主回应称将配合调查
  • “彩虹滑道”项目两男童相撞飞跌出去,景区:工作人员误判导致
  • 全国铁路昨日发送2311.9万人次,同比增长11.7%创历史新高