Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in httpsConnection  RSS feed

 
Preeti Arora
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using a webservice for authorizing credit card details.
The url for this is suppose:

https://test.otherwebsite.com?userid=11&pwd=535

Now this will generate some response headers and I want to parse them to know whether transaction has been successful.So I wrote code:



I am using jboss server.
Now I get an error:

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.secrtpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Can anyone tell how can I resolve this error.Also ,when I directly copy and paste this link on browser then I am able to see the headers with no error.

Thanks.
 
Thilak Raj Surendra Babu
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using a webservice for authorizing credit card details.
The url for this is suppose:

https://test.otherwebsite.com?userid=11&pwd=535

Now this will generate some response headers and I want to parse them to know whether transaction has been successful.So I wrote code:


code:
--------------------------------------------------------------------------------

URL url = new URL("https://test.otherwebsite.com?userid=11&pwd=535"); HttpsURLConnection huc = (HttpsURLConnection) url.openConnection(); huc.connect(); InputStream is = huc.getInputStream(); out.println("code:"+huc.getResponseCode()); huc.disconnect();

--------------------------------------------------------------------------------



I am using jboss server.
Now I get an error:

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.secrtpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Can anyone tell how can I resolve this error.Also ,when I directly copy and paste this link on browser then I am able to see the headers with no error.

Thanks.
Hi,
The problem you face is that the server gives a certificate which you were not able to verify with the CA certs available on your CAcerts keystore.Which is usually in "jre/lib/security/cacerts" import the certificate that was sent by your server to this keystore.
 
Preeti Arora
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much for reply.
I am just using a trial certificate and it is in conf directory of jboss.
Can you tell me more details on how to import?

Thanks again.
 
Thilak Raj Surendra Babu
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much for reply.
I am just using a trial certificate and it is in conf directory of jboss.
Can you tell me more details on how to import?

Thanks again.
Hi,
The server sends a server certificate which needs to be verified with the help of cacerts on your machine.Try Importing the certificate of the server using keytool or alternatively go through this site which would be very useful "http://blogs.sun.com/andreas/entry/no_more_unable_to_find"

Thanks
Thilak Raj S
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!