I am developing a WS client using JAVA and I have a problem with SSL authentication. WSs are created in WCF, and I do not have access to the server, they work through HTTPS and use a client certificate, which must be installed on the client first. The guys from the server sent me a PFX certificate that I successfully installed on the OS (I use OS X), and I could access WS through a browser (Safari or FF are the ones I tried that previously could not access WS). I thought that any application in the OS would use these certificates, but when I tried my JAVA application, it did not work; First, the following error was selected:
"javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: could not create PKIX path: sun.security.provider.certpath.SunCertPathBuilderException: could not find a valid certification path for the requested target
I solved this by exporting the certificate to a CER file and using the keytool command-line tool to add the certificate to the "cacerts" keyStore JAVA. But after this error disappeared, the following appeared: "403, prohibited." This is obvious due to the fact that he does not use an SSL client certificate for the site, but I could not find a way to send it to him. Any help would be appreciated.
The following is the code I'm using to publish to WS:
URL url = new URL(p_url); HttpsURLConnection conn = (HttpsURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", contentType); OutputStream out = conn.getOutputStream();
source share