将自签名https证书添加到teamcity后,TeamCity构建代理将断开连接

Run*_*sen 16 security teamcity https build-agent teamcity-7.0

我向我的Teamcity BuildServer添加了一个自签名证书,以引入https支持,以便现在可以访问它

https://ServerUrl:8443
Run Code Online (Sandbox Code Playgroud)

(更多细节如何在这里)

结果是我能够通过https访问服务器,但我的构建代理现在已断开连接.如何解决这个问题?

Run*_*sen 22

构建代理充当构建服务器的客户端并使用http/https与其进行通信,结果发现当您添加自签名证书时,构建代理不接受它.

我需要

  1. 让构建代理知道与服务器通信的新路径
  2. 让构建代理知道它可以信任自签名证书

要更改路径,我执行了以下操作(有关详细信息,请参阅此帖子)

找到该文件:
$ TEAMCITY_HOME/buildAgent/conf/buildAgent.properties

将属性
serverUrl = http:\:// localhost \:8080更改为新URL

为了让构建代理知道它可以信任新证书,我必须将其导入构建代理的密钥存储区.这是使用keytool完成的:

keytool -importcert -file <cert file>  
        -keystore <agent installation path>/jre/lib/security/cacerts
Run Code Online (Sandbox Code Playgroud)

(除非你更改了它,密钥库受密码保护:changeit)

在TeamCity的团队描述了稍微细节这个过程在这里

注意
如果需要从TeamCity构建服务器密钥库检索证书,还可以使用keytool执行此操作:

keytool -export -alias <alias name>  
        -file <certificate file name> 
        -keystore <Teamcity keystore path>
Run Code Online (Sandbox Code Playgroud)


Dav*_*lpy 5

这是keytool 上 TeamCity v8 文档的链接

我在 Windows Build Agent 上执行此操作,并且在我的 Amazon Linux Build Server 上有一个自签名 SSL 证书。以下是我采取的步骤:

  1. 去构建代理的浏览器中构建服务器,即https://teamcity.example.com
  2. 点击URL中的证书错误,将证书下载到本地
  3. 将证书从 Windows 中的证书资源管理器导出到 cer 文件中。
  4. 完全按照文档中的说明使用 keytool

    > keytool -importcert -file <cert file where it was exported to> 
      -keystore <path to JRE installation>/lib/security/cacerts
    password: changeit
    
    Run Code Online (Sandbox Code Playgroud)
  5. 重新启动构建代理和中提琴!