首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PKIX路径构建失败:

PKIX路径构建失败:
EN

Stack Overflow用户
提问于 2018-12-01 15:59:25
回答 1查看 486关注 0票数 0

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

代码语言:javascript
复制
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);
EN

回答 1

Stack Overflow用户

发布于 2019-05-17 02:55:57

您需要将SSL证书添加到您的java密钥库。我假设您使用的是windows机器。您将需要从命令提示符运行以下命令。

代码语言:javascript
复制
"%JAVA_HOME%\bin\keytool" -import -trustcacerts -keystore "%JAVA_HOME%\jre\lib\security\cacerts" -storepass changeit -alias CERTIFICATE -import -file CERTIFICATE.crt
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53568930

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档