【问题标题】:"Error validating server certificate" on SVN checkout using SvnAnt使用 SvnAnt 在 SVN 结帐时出现“验证服务器证书时出错”
【发布时间】:2016-06-09 10:40:37
【问题描述】:

我是 Ant 脚本的新手。我正在尝试使用 Ant 脚本从 SVN 存储库中签出。请在下面找到我的 Ant 脚本。

我正在使用詹金斯。创建了一个新项目并根据 ant 文件的路径设置调用 ant build(ant 目标是 dist)。

我能够通过 root 用户签出代码并能够在 Jenkinstools(源代码管理)中进行。但是从 Jenkins -> Ant 脚本构建执行时,它显示以下错误:

服务器证书验证失败:为不同的主机名颁发证书,颁发者不受信任

<project name="ProjectBuid" basedir=".">

<description>
    simple example build file
</description>
<property environment="env" />
<property name="svn.username" value="NANI" />
<property name="svn.password" value="Pandu" />
<property name="code.base.location" value="${env.WORKSPACE}" />
<property name="lib.home" value="..\lib" />
<property name="{svnPathParam}" value="https://Ip:port/Build/" />

<property name="jenkins-url" value="http://IP1" />
<property name="auth-username" value="root" />
<property name="auth-pwd" value="1231231231231" />
<property name="cli.prefix" value="AB_CLI_" />

<path id="mvn.classpath">
    <pathelement location="${lib.home}\maven-ant-tasks-2.1.3.jar" />
</path>
<path id="svnant.classpath">
    <pathelement location="${lib.home}\svnant.jar" />
    <pathelement location="${lib.home}\svnClientAdapter.jar" />
    <pathelement location="${lib.home}\svnkit.jar" />
    <pathelement location="${lib.home}\ganymed.jar" />
    <pathelement location="${lib.home}\svnjavahl.jar" />
</path>

<tstamp>
    <format property="START_TIME" pattern="dd_MMM_yy_HH_mm_ss" />
</tstamp>
<property name="timestamp" value="${START_TIME}" />
<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask"
    classpath="${lib.home}\xmltask.jar" />
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
    <classpath>
        <pathelement location="${lib.home}\ant-contrib-1.0b3.jar" />
    </classpath>
</taskdef>

<typedef resource="org/tigris/subversion/svnant/svnantlib.xml"
    classpathref="svnant.classpath" />
<svnSetting svnkit="false" javahl="false" id="svn.settings"
    username="${svn.username}" password="${svn.password}" />

<target name="dist" description="checkout code">
    <mkdir dir="${code.base.location}/${timestamp}" />
    <exec dir="${code.base.location}/${timestamp}" executable="svn">
        <arg value="co" />
        <arg value="${svnPathParam}" />
        <arg value="." />
    </exec>
    <!-- On executing above, error: Error validating server certificate for 
        'https://IP': [exec] - The certificate is not issued by a trusted authority. 
        Use the [exec] fingerprint to validate the certificate manually! [exec] - 
        The certificate hostname does not match. [exec] Certificate information: 
        [exec] - Hostname: IP [exec] - Valid: from XXXXXXX until yyyyyyyyyyyy [exec] 
        - Issuer: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX [exec] - Fingerprint: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 
        [exec] (R)eject, accept (t)emporarily or accept (p)ermanently? svn: OPTIONS 
        of 'https://Ip/build': Server certificate verification failed: certificate 
        issued for a different hostname, issuer is not trusted (https://IP) <!--Or 
        and also tried as below -->
    <svn refid="svn.settings">
        <checkout url="${svnPathParam}" destPath="${code.base.location}\${timestamp}" />
    </svn>
    <!-- On choosing above, error: svn: OPTIONS of 'https://Ip/build': Server 
        certificate verification failed: certificate issued for a different hostname, 
        issuer is not trusted (https://IP) [svn] <Checkout> failed. -->
</target>

【问题讨论】:

  • 您是否尝试通过其 IP 而不是主机名访问 https 站点?但是..您不能以正确的用户身份手动运行svn co 并永久接受证书吗?
  • 如果您使用的是 Jenkins,您是否考虑过配置构建作业来执行结帐,而不是在 ANT 中运行它?如果您希望所有配置都本地化,新的 Jenkins 管道功能允许您将构建作业配置保存在“Jenkinsfile”中。见:jenkins.io/solutions/pipeline

标签: svn jenkins ant svnant


【解决方案1】:

正确且有效的解决方案是使用与您用来访问远程服务器的 FQDN 或主机名匹配的有效证书。所有其他建议只是解决方法,它们有点难看。您不应该绕过证书验证,因为从安全角度来看它非常糟糕。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-02
    • 1970-01-01
    • 2013-07-09
    • 1970-01-01
    相关资源
    最近更新 更多