troubleshooting Question

Accessing a file via HTTPS to JBoss

Avatar of mwalker
mwalkerFlag for United States of America asked on
Java
1 Comment1 Solution311 ViewsLast Modified:
All,

I'm desperately need to access a file within my Java application via an HttpsURLConnection to a JBoss application server (where the pathName contains "https").  I tried the following code:

            // Establish a connection with the application server to the descriptor file
            URL url = new URL(pathName);
            HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
            conn.setHostnameVerifier(new HostnameVerifier() {
          public boolean verify(String hostname, SSLSession session) {
             // I don't care if the certificate doesn't match host name
             return true;
          }
        });
            conn.setRequestMethod("GET");
            conn.setDoInput(true);
            conn.connect();

I get the following exeption:

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found
      at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.a(DashoA12275)
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA12275)
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA12275)
      at com.sun.net.ssl.internal.ssl.SunJSSE_az.a(DashoA12275)
      at com.sun.net.ssl.internal.ssl.SunJSSE_az.a(DashoA12275)
      at com.sun.net.ssl.internal.ssl.SunJSSE_ax.a(DashoA12275)
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA12275)
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.j(DashoA12275)
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.b(DashoA12275)
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(DashoA12275)
      at sun.net.www.protocol.https.HttpsClient.afterConnect(DashoA12275)
      at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(DashoA12275)
      at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(DashoA12275)
      at com.portware.thirdpartylicense.ThirdPartyLicenseClient.fetchFile(ThirdPartyLicenseClient.java:83)
      at com.portware.thirdpartylicense.ThirdPartyLicenseClient.<init>(ThirdPartyLicenseClient.java:53)
      at com.portware.thirdpartylicense.ThirdPartyLicenseClient.getInstance(ThirdPartyLicenseClient.java:30)
      at com.indigo.neuron.gui.HelpMenuMediator$7.run(HelpMenuMediator.java:194)
      at java.lang.Thread.run(Thread.java:534)
Caused by: sun.security.validator.ValidatorException: No trusted certificate found
      at sun.security.validator.SimpleValidator.buildTrustedChain(SimpleValidator.java:304)
      at sun.security.validator.SimpleValidator.engineValidate(SimpleValidator.java:107)
      at sun.security.validator.Validator.validate(Validator.java:202)
      at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(DashoA12275)
      at com.sun.net.ssl.internal.ssl.JsseX509TrustManager.checkServerTrusted(DashoA12275)

Can anyone give me (or point me to) code examples for doing this with JBoss?  Thank you in advance.
ASKER CERTIFIED SOLUTION
Ajay-Singh

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros