使用Maven PKIX路径构建失败SSLHandshakeException

时间:2015-01-08 11:59:25

标签: java maven ssl-certificate

我正在尝试从命令提示符运行mvn install我收到以下异常。

        Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.Validator
        Exception: PKIX path building failed: sun.security.provider.certpath.SunCertPath
        BuilderException: unable to find valid certification path to requested target
                at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
                at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1836)
                at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:276)
                at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:270)
                at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.
        java:1337)
                at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.jav
        a:154)
                at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868)
                at sun.security.ssl.Handshaker.process_record(Handshaker.java:804)
                at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:966)
                at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.
        java:1262)
                at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1289
        )
                at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1273
        )
                at org.apache.maven.wagon.providers.http.httpclient.conn.ssl.SSLConnecti
        onSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:280)
                at org.apache.maven.wagon.providers.http.httpclient.impl.conn.HttpClient
        ConnectionOperator.upgrade(HttpClientConnectionOperator.java:167)
                at org.apache.maven.wagon.providers.http.httpclient.impl.conn.PoolingHtt
        pClientConnectionManager.upgrade(PoolingHttpClientConnectionManager.java:329)
                at org.apache.maven.wagon.providers.http.httpclient.impl.execchain.MainC
        lientExec.establishRoute(MainClientExec.java:392)
                at org.apache.maven.wagon.providers.http.httpclient.impl.execchain.MainC
        lientExec.execute(MainClientExec.java:218)
                at org.apache.maven.wagon.providers.http.httpclient.impl.execchain.Proto
        colExec.execute(ProtocolExec.java:194)
                at org.apache.maven.wagon.providers.http.httpclient.impl.execchain.Retry
        Exec.execute(RetryExec.java:85)
                at org.apache.maven.wagon.providers.http.httpclient.impl.execchain.Redir
        ectExec.execute(RedirectExec.java:108)
                at org.apache.maven.wagon.providers.http.httpclient.impl.client.Internal
        HttpClient.doExecute(InternalHttpClient.java:186)
                at org.apache.maven.wagon.providers.http.httpclient.impl.client.Closeabl
        eHttpClient.execute(CloseableHttpClient.java:82)
                at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.execute
        (AbstractHttpClientWagon.java:756)
                at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.fillInp
        utData(AbstractHttpClientWagon.java:854)
                ... 8 more
        Caused by: sun.security.validator.ValidatorException: PKIX path building failed:
         sun.security.provider.certpath.SunCertPathBuilderException: unable to find vali
        d certification path to requested target
                at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:385)
                at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.jav
        a:292)
                at sun.security.validator.Validator.validate(Validator.java:260)
                at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.j
        ava:326)
                at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerIm
        pl.java:231)
                at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustMan
        agerImpl.java:126)
                at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.
        java:1319)
                ... 27 more
        Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to
         find valid certification path to requested target
                at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCert
        PathBuilder.java:196)
                at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:268)
                at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:380)
                ... 33 more

当我尝试运行mvn clean时,它正常工作。

我试着用谷歌搞清楚,上述错误是由认证错误引起的。

我下载InstallCert.java文件并运行它并将文件复制粘贴到" C:\ Program Files \ Java \ jdk1.7.0 \ bin"

但仍然收到认证错误。

我做错了吗?

2 个答案:

答案 0 :(得分:0)

我发现您需要在 settings.xml 文件中启用服务器设置。

例如:

<server>
  <id>deploymentRepo</id>
  <username>****</username>
  <password>****</password>
</server>

这使我能够克服SSL证书错误。

答案 1 :(得分:0)

解决方案下载root ca ssl证书并将其安装到maven使用的jre的cacerts文件中!Checkout this完整答案它非常具有描述性。