sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求的目标错误的有效证书路径 [英] sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target error

查看:890
本文介绍了sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求的目标错误的有效证书路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行以下代码的地方出现错误:

Where I run the below code I get the error:

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

我尝试将证书添加到JDK的CAcerts密钥库中,但错误没有更改.他们是否仍然想知道它从哪个密钥库读取?还是这个问题?

I have tried to add the Certificate to the CAcerts keystore for the JDK but with no change in the error. Is their anyway to figure out what keystore it is reading from? Or is this problem something else?

public static void main(String args[]) throws Exception {

        SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
        SOAPConnection soapConnection = soapConnectionFactory.createConnection();


        String url = "https://www.mywebservice.com/ws";


    SOAPMessage soapResponse = soapConnection.call(createSOAPRequest(),url);



        // print SOAP Response
        System.out.print("Response SOAP Message:");
        soapResponse.writeTo(System.out);

        soapConnection.close();


    }

感谢您和我会提供所需的其他详细信息.

Thank you and I will happily provide any other details required.

推荐答案

您必须将服务器证书或根CA添加到JDK使用的信任库中.默认情况下使用jre/lib/security/cacerts.

You have to add the server certificate, or the root CA to the truststore used by JDK. By default is used jre/lib/security/cacerts.

如果您已经导入了服务器证书,则请验证您实际上使用的是正确的JDK,还是证书已成功导入.您可以使用 http://www.keystore-explorer.org/之类的GUI工具,也可以使用keytool

If you already imported the server certificate, then verify that you are actually using the correct JDK, or the certificate is successfully imported. You can use a GUI tool like http://www.keystore-explorer.org/ or use keytool

您还可以使用包含服务器证书的JKS文件来使用自己的托管人(推荐).以这种方式配置用法

You can also use your own trustore (recommended) using a JKS file which includes the server certificate. Configure the usage in this way

System.setProperty ("javax.net.ssl.trustStore", path_to_your_trustore_jks_file);
System.setProperty ("javax.net.ssl.trustStorePassword", "password");

这篇关于sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求的目标错误的有效证书路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆