SSL HttpsUrlConnection

Ads

 
 

Share on Google+Share on Google+

Luciano Santos
SSL HttpsUrlConnection
2 Answer(s)      6 years and 10 months ago
Posted in : Security

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"));
Ads
View Answers

March 11, 2011 at 3:00 PM


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



March 11, 2011 at 6:14 PM


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.


Ads









Related Tutorials/Questions & Answers:
SSL HttpsUrlConnection
SSL HttpsUrlConnection  Hi, My name is Luciano, I am trying to implement a ssl comunication between a desktop application and a web application. I... is: URL page = new URL(url); HttpsURLConnection connection
ssl client - JSP-Servlet
ssl client  How do you write SSL Client? Take example of SSL Socket Client
Advertisements
SSL Authentication - JSP-Servlet
SSL Authentication  With the help of a sample code describe the use of SSL Authentication of java clients
SSL for login page
SSL for login page  I am trying to apply ssl cert to login page only. Does anyone know how to do this on a tomcat web server
Version of tmporb>tmporb-ssl dependency
List of Version of tmporb>tmporb-ssl dependency
SSL Certificates
SSL Certificates Secure Sockets Layer or SSL for short is a protocol. It was developed by Netscape for transmitting private documents over internet. SSL.... URLs requiring the SSL connection starts with https: instead of http
Version of activemq>activemq-transport-ssl dependency
List of Version of activemq>activemq-transport-ssl dependency
Version of mule>mule-ssl-provider dependency
List of Version of mule>mule-ssl-provider dependency
Version of ca.juliusdavies>not-yet-commons-ssl dependency
List of Version of ca.juliusdavies>not-yet-commons-ssl dependency
Version of com.cloudhopper>ch-commons-ssl dependency
List of Version of com.cloudhopper>ch-commons-ssl dependency
Version of com.floragunn>search-guard-ssl dependency
List of Version of com.floragunn>search-guard-ssl dependency
Version of com.intersult>ssl-maven-plugin dependency
List of Version of com.intersult>ssl-maven-plugin dependency
Maven Dependency tmporb-ssl >> 1.0
You should include the dependency code given in this page to add Maven Dependency of tmporb >> tmporb-ssl version1.0 in your project
Steps For SSL Implementation/Enabling in Apache Tomcat 6.0
Steps For SSL Implementation/Enabling in Apache Tomcat 6.0   Hi , I am using the NetBeans 6.9 IDE Apache Tomcat 6.0 as Web server Front end jsp-servlet please gives me complete guidance steps ,code for SSL Implementation
Steps For SSL Implementation/Enabling in Apache Tomcat 6.0
Steps For SSL Implementation/Enabling in Apache Tomcat 6.0   Hi , I am using the NetBeans 6.9 IDE Apache Tomcat 6.0 as Web server Front end jsp-servlet please gives me complete guidance steps ,code for SSL Implementation
ssl comunication between a desktop application and a web application
ssl comunication between a desktop application and a web application  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
Maven Dependency activemq-transport-ssl >> 1.1-G1M3
You should include the dependency code given in this page to add Maven Dependency of activemq >> activemq-transport-ssl version1.1-G1M3 in your project
Maven Dependency activemq-transport-ssl >> 1.2
You should include the dependency code given in this page to add Maven Dependency of activemq >> activemq-transport-ssl version1.2 in your project
Maven Dependency activemq-transport-ssl >> 1.3
You should include the dependency code given in this page to add Maven Dependency of activemq >> activemq-transport-ssl version1.3 in your project
Maven Dependency activemq-transport-ssl >> 1.4
You should include the dependency code given in this page to add Maven Dependency of activemq >> activemq-transport-ssl version1.4 in your project
Maven Dependency activemq-transport-ssl >> 1.5
You should include the dependency code given in this page to add Maven Dependency of activemq >> activemq-transport-ssl version1.5 in your project
Maven Dependency activemq-transport-ssl >> 2.0
You should include the dependency code given in this page to add Maven Dependency of activemq >> activemq-transport-ssl version2.0 in your project
Maven Dependency activemq-transport-ssl >> 2.1
You should include the dependency code given in this page to add Maven Dependency of activemq >> activemq-transport-ssl version2.1 in your project
Maven Dependency mule-ssl-provider >> 1.0
You should include the dependency code given in this page to add Maven Dependency of mule >> mule-ssl-provider version1.0 in your project
Maven Dependency mule-ssl-provider >> 1.0-rc3
You should include the dependency code given in this page to add Maven Dependency of mule >> mule-ssl-provider version1.0-rc3 in your project
Maven Dependency mule-ssl-provider >> 1.1
You should include the dependency code given in this page to add Maven Dependency of mule >> mule-ssl-provider version1.1 in your project
Maven Dependency mule-ssl-provider >> 1.1.1
You should include the dependency code given in this page to add Maven Dependency of mule >> mule-ssl-provider version1.1.1 in your project
Maven Dependency mule-ssl-provider >> 1.1-rc1
You should include the dependency code given in this page to add Maven Dependency of mule >> mule-ssl-provider version1.1-rc1 in your project
Maven Dependency mule-ssl-provider >> 1.2
You should include the dependency code given in this page to add Maven Dependency of mule >> mule-ssl-provider version1.2 in your project
Maven Dependency not-yet-commons-ssl >> 0.3.11
You should include the dependency code given in this page to add Maven Dependency of ca.juliusdavies >> not-yet-commons-ssl version0.3.11 in your project
Maven Dependency not-yet-commons-ssl >> 0.3.9
You should include the dependency code given in this page to add Maven Dependency of ca.juliusdavies >> not-yet-commons-ssl version0.3.9 in your project

Ads

 
Advertisement null

Ads