自签名证书 - 无法使用ANT Build进行连接 [英] Self-signed Certificate - Unable to connect using ANT Build
问题描述
我正在尝试连接到特定网页中的所有链接,并获得响应以查看链接是否损坏。
某些链接是自我认证的SSL。
所以,我按照将证书添加到信任存储的过程。之后,它工作正常,当我在Eclipse中测试相同(它返回OK / 200)。
但是,当我使用命令行中的ANT构建和运行项目时,会出现同样的异常。
这是奇怪的,当我通过Eclipse构建使用相同的xml不会发生;它只是工作!
I'm trying to connect to all the links in a particular webpage and get the response to see if the link is broken.
Some of the links are SSL that too self-certified.
So, I've followed the procedure of adding the certificate to trust store. After that it worked fine, when I tested the same in Eclipse(it returned OK/200).
But, when I build and run the project using ANT in command line, the same exception appears.
And it is weird that it doesn't happen when I build using the same xml through Eclipse; it simply works!
sun.security.validator.ValidatorException:PKIX路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到有效的认证路径到请求的目标
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
推荐答案
根据我以前的评论,Java安装了一个JRE与JDK一起,而JDK又安装了一个JRE。因此,如果您不确定使用哪一个,可以尝试将证书添加到jre\lib\security\cacerts和jdk1.x.0_xx\jre\lib\security\cacerts中。
As per my previous comments Java installs a JRE alongside the JDK which in turn also has a JRE installed. Thus if you are not sure which one is used you can try to add the certificate into jre\lib\security\cacerts and jdk1.x.0_xx\jre\lib\security\cacerts.
这篇关于自签名证书 - 无法使用ANT Build进行连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!