首页 > 解决方案 > SSL 证书问题:无法获取本地颁发者证书,Jenkins 中的 git clone/pull

问题描述

我们有一个 Jenkins 构建作业,它执行了一个执行 git clone/pull 的 ANT 目标(我们没有使用 Jenkins Git 插件)。

<macrodef name="git">
        <attribute name="command" />
        <attribute name="dir" default="" />
        <element name="args" optional="true" />
        <sequential>
            <echo message="git @{command}" />
            <exec executable="git" dir="@{dir}">
                <arg value="@{command}" />
                <args/>
            </exec>
        </sequential>
</macrodef>
<macrodef name="git-clone-pull">
        <attribute name="repository" />
        <attribute name="dest" />
        <sequential>
            <git command="clone">
                <args>
                    <arg value="@{repository}" />
                    <arg value="@{dest}" />
                </args>
            </git>
            <git command="pull" dir="@{dest}" />
        </sequential>
</macrodef>

<target name="clone-pull-git-repository">
    <echo message="# Cloning '${git.repository}':" />
    <git-clone-pull 
    repository="https://${git.user}:${git.password}@${git.repository.url}/grsbrms/${git.repository}" 
    dest="${git.repository.dir}/${git.repository}" />
</target>

在最近的 Bitbucket 迁移之后,我们看到了以下错误。

[echo] git pull
[exec] fatal: unable to access 'https://TestUser:xyz@bitbucket.somecorp.com/scm/grs-brms-payroll-xom/': SSL certificate problem: unable to get local issuer certificate

我们尝试将 ssl 证书从网站导入 JVM:

keytool -import -alias SV12345 -keystore %JAVA_HOME%\jre\lib\security\cacerts -file C:\Temp\bitbucket.cer

并且还将证书添加到 Jenkins 启动脚本中:

-Djavax.net.ssl.trustStore=%JENKINS_HOME%\.cacerts\cacerts
-Djavax.net.ssl.trustStorePassword=changeit

是否可以在不关闭 git 系统范围的 SSL 验证的情况下解决此问题?

即 git config --system http.sslVerify false

谢谢

标签: gitssljenkinsant

解决方案


推荐阅读