解决极狐GitLab release 关键字使用中 x509 证书不受信任的问题

release 关键是极狐GitLab CI/CD 中用来发布版本的一个关键字,通常用法如下:

release_job:stage: releaseimage: registry.gitlab.com/gitlab-org/release-cli:latestrules:- if: $CI_COMMIT_TAG                 script:- echo "running release_job"release:                              tag_name: '$CI_COMMIT_TAG'description: '$CI_COMMIT_TAG'

整个过程是通过 release-cli 工具来实现的。

近期在探索CI/CD Component & CI/CD Catalog 功能的时候,也是使用 release 关键字将 component 发布到 Catalog 中。

create-release:stage: deployimage: registry.gitlab.com/gitlab-org/release-cli:latestscript: echo "Creating release $CI_COMMIT_TAG"rules:- if: $CI_COMMIT_TAGrelease:tag_name: $CI_COMMIT_TAGdescription: "Release $CI_COMMIT_TAG of components in $CI_PROJECT_PATH"

由于采用了自签名(self-signed certificate)的证书进行了 HTTPS 的配置,在用私有化部署的极狐GitLab 实例做测试时,就会出现 x509 证书不受信任的问题:

$ release-cli create --description "Release 2.0.0 of components in jh-gitlab/cicd-component" --tag-name "2.0.0"
time="2024-02-04T06:38:08Z" level=info msg="Creating Release..." cli=release-cli command=create name= project-id=1 ref=e8786a8fd333280dbfe480417237f97d6f6a7182 server-url="https://jhma.jihulab.net" tag-message= tag-name=2.0.0 version=0.16.0
time="2024-02-04T06:38:09Z" level=fatal msg="run app" cli=release-cli error="failed to create release: failed to do request: Post \"https://jhma.jihulab.net/api/v4/projects/1/releases\": tls: failed to verify certificate: x509: certificate signed by unknown authority" version=0.16.0

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

针对这个问题,有以下两种解决方案。

方法一:设置 --insecure-https 参数

release-cli 的使用方法如下:

release-cli -h
NAME:release-cli - A CLI tool that interacts with GitLab's Releases APIUSAGE:help [global options] command [command options] [arguments...]VERSION:0.16.0DESCRIPTION:CLI tool that interacts with GitLab's Releases API https://docs.gitlab.com/ee/api/releases/.All configuration flags will default to GitLab's CI predefined environment variables (https://docs.gitlab.com/ee/ci/variables/predefined_variables.html).To override these values, use the [GLOBAL OPTIONS].Get started with release-cli https://gitlab.com/gitlab-org/release-cli.AUTHOR:GitLab Inc. <support@gitlab.com>COMMANDS:create            Create a Release using GitLab's Releases API https://docs.gitlab.com/ee/api/releases/#create-a-releasecreate-from-file  Create a Release using GitLab's Releases API https://docs.gitlab.com/ee/api/releases/#create-a-releaseget               Get a Release by tag name using GitLab's Releases API https://docs.gitlab.com/ee/api/releases/index.html#get-a-release-by-a-tag-nameupdate            Update a release using GitLab's Releases API https://docs.gitlab.com/ee/api/releases/#update-a-releasehelp, h           Shows a list of commands or help for one commandGLOBAL OPTIONS:--server-url value                 The base URL of the GitLab instance, including protocol and port, for example https://gitlab.example.com:8080 (default: "https://jhma.jihulab.net") [$CI_SERVER_URL]--job-token value                  Job token used for authenticating with the GitLab Releases API (default:  ) [$CI_JOB_TOKEN]--project-id value                 The current project's unique ID; used by GitLab CI internally (default: "1") [$CI_PROJECT_ID]--timeout value                    HTTP client's timeout in Go's duration format https://golang.org/pkg/time/#ParseDuration (default: 30s) [$RELEASE_CLI_TIMEOUT]--private-token value              Private token used for authenticating with the GitLab Releases API, requires api scope https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html, overrides job-token (default:  ) [$GITLAB_PRIVATE_TOKEN]--additional-ca-cert-bundle value  Configure a custom SSL CA certificate authority, can be a path to file or the content of the certificate [$ADDITIONAL_CA_CERT_BUNDLE]--insecure-https                   Set to true if you want to skip the client verifying the server's certificate chain and host name (default: false) [$INSECURE_HTTPS]--debug                            Set to true if you want extra debug output when running release-cli (default: false) [$DEBUG]--help, -h                         Show help (default: false)--version, -v                      Print the version (default: false)
/ # release-cli create -h
NAME:help create - Create a Release using GitLab's Releases API https://docs.gitlab.com/ee/api/releases/#create-a-releaseUSAGE:help create [command options] [arguments...]OPTIONS:--tag-name value     (required) The tag the release will be created from (default: "1.0.0") [$CI_COMMIT_TAG]--name value         The release name--description value  The description of the release; you can use Markdown. A file can be used to read the description contents, must exist inside the working directory; if it contains any whitespace, it will be treated as a string--tag-message value  Message to use if creating a new annotated tag--ref value          If tag_name doesn’t exist, the release will be created from ref; it can be a commit SHA, another tag name, or a branch name (default: "8b4838090bb46bf40ed77027feae074a47e6a132") [$CI_COMMIT_SHA]--assets-link value  JSON string representation of an asset link; (e.g. --assets-link='{"name": "Asset1", "url":"https://<domain>/some/location/1", "type": "other", "filepath": "xzy" }' or --assets-link='[{"name": "Asset1", "url":"https://example.com/some/location/1"}, {"name": "Asset2", "url":"https://example.com/some/location/2"}]'  (accepts multiple inputs)--milestone value    List of the titles of each milestone the release is associated with (e.g. --milestone "v1.0" --milestone "v1.0-rc)"; each milestone needs to exist                                                                                                                                                                          (accepts multiple inputs)--released-at value  The date when the release will be/was ready; defaults to the current time; expected in ISO 8601 format (2019-03-15T08:00:00Z)--help, -h           Show help (default: false)

里面有一个参数 --insecure-https ,描述为 Set to true if you want to skip the client verifying the server's certificate chain and host name (default: false) [$INSECURE_HTTPS]。也就是说,如果想要跳过客户端对于服务器证书验证的话,就需要将这个参数设置为 true,而这个参数默认是 false。也就是默认情况下会进行证书验证。

所以,可以在 CI/CD 流水线中使用 --insecure-https 参数:

create-release:stage: deployimage: name: registry.gitlab.com/gitlab-org/release-cli:latestscript:- release-cli --insecure-https=true create --name "Release $TAG" --description "Release $CI_COMMIT_TAG of components in $CI_PROJECT_PATH" --tag-name "$CI_COMMIT_TAG"tags:- jhrules:- if: $CI_COMMIT_TAG =~ /\d+/

接着触发 CI/CD 流水线,可以看到构建成功:

在这里插入图片描述

方法二:设置证书

同样在 release-cli 的使用中有一个关于证书的参数 --additional-ca-cert-bundle,描述为 Configure a custom SSL CA certificate authority, can be a path to file or the content of the certificate [$ADDITIONAL_CA_CERT_BUNDLE]。也就是说可以直接制定服务器证书的路径。

所以,CI/CD 流水线就变为了:

create-release:stage: deployimage: name: registry.gitlab.com/gitlab-org/release-cli:latestscript:- release-cli --additional-ca-cert-bundle="path/to/certificate" create --name "Release $TAG" --description "Release $CI_COMMIT_TAG of components in $CI_PROJECT_PATH" --tag-name "$CI_COMMIT_TAG"tags:- jhrules:- if: $CI_COMMIT_TAG =~ /\d+/

接着触发 CI/CD 流水线,可以看到构建成功:

在这里插入图片描述
这两种方式都可以解决自签名证书带来的证书不受信任问题。不过如果是生产环境,建议使用购买的 CA,这样这个问题就不存在了。

更多关于极狐GitLab & DevOps 的最佳实践。可以搜索并关注【极狐GitLab】公众号。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/451877.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

开源软件:技术创新与应用的推动力量

文章目录 每日一句正能量前言开源软件如何推动技术创新开源软件的历史开源软件的开发模式开源软件与闭源软件源代码和开发许可维护特点、支持和成本开源软件的优势减少开支可定制性快速创新发展透明度和安全性 开源软件的应用 常见问题后记 每日一句正能量 不好等待运气降临&am…

【已解决】Oracle 12541 TNS 无监听程序

目录 1、找到Oracle监听服务&#xff08;OracleOraDb10g_homeTNLListener&#xff09;&#xff0c;停止运行 2、首先查看监听文件是否超过4G 3、修改配置文件 连接oracle突然报错&#xff0c;提示Oracle 12541 TNS 无监听程序&#xff0c;可以按照以下步骤解决 1、找到Ora…

【用Unity开发一款横板跳跃游戏部分需要学习的技术点指南】

*** 用Unity开发一款横板跳跃游戏部分需要学习的技术点指南 空洞骑士是一款基于横板平台跳跃的传统风格2D动作冒险游戏&#xff0c;庞大的游戏世界交错相通&#xff0c;玩家控制小虫子去探索幽深黑暗的洞穴&#xff0c;成为了一代人茶余饭后的惦念&#xff0c;深受玩家喜爱。 …

【C++】类和对象3:默认成员函数之构造函数

前言 今天来初步了解一下类的6个默认成员函数 引入 默认成员函数&#xff1a;用户没有显式实现&#xff0c;编译器会生成的成员函数称为默认成员函数 下面是六个默认成员函数的图解 构造函数 概念 class Date { public:void Init(int year, int month, int day){_year …

layui

基于复杂结构的自定义模版相关介绍 我这里的接口给的格式数据 我这里搜索往返时候要显示成这样的 layui.use([table,form], function(){ var table layui.table; var form layui.form;// 渲染表格 table.render({ elem: #test-table-reload,toolbar: #toolbarDemo, …

2023年全球软件架构师峰会(ArchSummit上海站):核心内容与学习收获(附大会核心PPT下载)

微服务架构是当今软件架构的主流趋势之一。随着云计算和分布式系统的普及&#xff0c;越来越多的企业开始采用微服务架构来构建他们的应用。微服务架构可以将一个大型的应用拆分成多个小型的服务&#xff0c;每个服务都独立部署、独立运行&#xff0c;并通过轻量级的通信协议进…

如何使用第三方API采集电商数据呢?

电商商家最常唠叨的就是店铺运营难做。每日多平台店铺数据统计汇总繁琐耗时&#xff0c;人工效率偏低&#xff0c;且工作内容有限。 特别是眼下“618&#xff0c;双十一&#xff0c;双十二&#xff0c;年底大促”将至&#xff0c;如何提高运营的效率和质量、保证产品及服务的良…

cesium-水平测距

cesium测量两点间的距离 <template><div id"cesiumContainer" style"height: 100vh;"></div><div id"toolbar" style"position: fixed;top:20px;left:220px;"><el-breadcrumb><el-breadcrumb-item&…

【数位dp】【动态规划】【KMP】1397. 找到所有好字符串

作者推荐 【动态规划】【字符串】【表达式】2019. 解出数学表达式的学生分数 本文涉及知识点 动态规划汇总 LeetCode1397. 找到所有好字符串 给你两个长度为 n 的字符串 s1 和 s2 &#xff0c;以及一个字符串 evil 。请你返回 好字符串 的数目。 好字符串 的定义为&#x…

用通俗易懂的方式讲解:12 个大模型 RAG 痛点及解决方案

受 Barnett 等人的论文《工程检索增强生成系统时的七个失败点》启发&#xff0c;让我们在本文中探讨论文中提到的七个失败点以及开发 RAG 管道时的五个常见痛点。 论文&#xff1a;https://arxiv.org/pdf/2401.05856.pdf 更重要的是&#xff0c;我们将深入探讨这些 RAG 痛点的…

【SpringBoot】模板设计模式应用

一、前言 常见的设计模式有23种&#xff0c;我们不得不提到模板方法设计模式&#xff0c;这是一种在软件开发中广泛使用的行为型设计模式之一。 二、模板方式是什么 全称是模板方法设计模式。 模板模式是一种行为设计模式。它的实现思路是&#xff0c;创建一个 模板方法 me…

转化率翻倍秘诀:打造私域标签体系的终极指南!

如今&#xff0c;私域运营逐渐成为企业标配甚至刚需。 但是大部分企业做私域只是从众&#xff0c;很少能真正想清楚做私域的目标和价值。要么是砸重金搭建团队&#xff0c;但是没有运营重心&#xff0c;最后转化效果很差&#xff1b;要么就是不太重视&#xff0c;人力精力投入…