0
votes

I am getting 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 exception , how to solve this?This is my keystore

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);
1

1 Answers

0
votes

You will need to add SSL certificate to your java keystore. I am assuming you are using a windows machine. You will need to run following command from your command prompt.

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