繁体   English   中英

PKIX路径构建失败:

[英]PKIX path building failed:

我正在获取javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException:PKIX路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求的目标异常的有效证书路径,如何解决呢?这是我的密钥库

KeyStore ks = KeyStore.getInstance("Windows-MY", "SunMSCAPI");
                String pin = " ";
                ks.load(null, pin.toCharArray());





    Protocol myProtocol = new Protocol("https", new MySSLSockectFactory(), 443);
                                        httpclient.getHostConfiguration()
                                                .setHost("test.euniwizarde.com", 443, myProtocol);

                                        HostConfiguration hostConfiguration = httpclient.getHostConfiguration();
                                        String hostURL = hostConfiguration.getHostURL();
                                        System.out.println("hostURL============" + hostURL);

                                        BufferedReader br = null;
                                        setVisible(false);

                                        PostMethod postMethod = new PostMethod(hostURL);
                                        System.out.println("postmethod " + postMethod);
                                        postMethod.addParameter("userid", "" + userId);
                                        postMethod.addParameter("serialNumber", "" + serialNumber);
                                        postMethod.addParameter("name", "" + name);
                                        postMethod.addParameter("publicKey", "" + publicKey);
                                        postMethod.addParameter("dateOfIssue", "" + dateOfIssue);
                                        postMethod.addParameter("expiry", "" + expiryDate);
                                        postMethod.addParameter("issuer", "" + issuer);
                                        postMethod.addParameter("var", " " + var);
                                        postMethod.addParameter("siteName", "" + siteName);
                                        boolean requestSent = postMethod.isRequestSent();

                                        System.out.println("Is request Sent before execute method===="+ requestSent);
                                        try {
                                            int returnCode = httpclient.executeMethod(postMethod);

您将需要向SSL密钥库添加SSL证书。 我假设您正在使用Windows计算机。 您将需要在命令提示符下运行以下命令。

"%JAVA_HOME%\bin\keytool" -import -trustcacerts -keystore "%JAVA_HOME%\jre\lib\security\cacerts" -storepass changeit -alias CERTIFICATE -import -file CERTIFICATE.crt

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM