Hi,
My name is Luciano, I am trying to implement a ssl comunication between a desktop application and a web application. I unable the https on JBoss and I have two files ca.crt and server.crt, I install the server crt on the browser and test the connection, all occour perfectly, But when I try connect using my desktop aplication i get the error:
Exception in thread "main" 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 at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1611) at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:187) at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:181) at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1035) at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:124) at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:516) at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:454)
I search the solution, but the most of response dont solve my problem, what can I do to solve this problem? The connection code is:
URL page = new URL(url); HttpsURLConnection connection = (HttpsURLConnection) page .openConnection(); File trustFile = new File("C:/myteste/truststore"); File keyFile = new File("C:/myteste/keystore"); connection.setDefaultSSLSocketFactory(this.getSSLSocketFactory( trustFile, "teste", keyFile, "teste"));
Hi Lusiano,
I am trying to implement a ssl comunication between a desktop application and a web application. can you please share code with me.
Please explain me 'connection.setDefaultSSLSocketFactory(this.getSSLSocketFactory( trustFile, "teste", keyFile, "teste"));' code. what is 'teste'?
Please help me.
thanks and regards
sivjava
Teste = Test, I am Brazilian
You don�´t need have a trustManager or KeyManager in code. You can install the certificate in the S.O and initialize the SSLContext with this code: context.init(null, null, null);
The SSLContext will be use the installed certificate.