473,405 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

https -- connection probs

I had the following code to connect to a site on a server. It worked fine, now the server is using https, which causes the error

javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: Couldn't find trusted certificate


Expand|Select|Wrap|Line Numbers
  1.         java.util.Properties propSy = System.getProperties();
  2.         propSy.put("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");
  3.  
  4.         System.setProperties(propSy);
  5.         java.security.Security.insertProviderAt(new sun.security.provider.Sun(),2);
  6.         java.security.Security.addProvider(new sun.security.provider.Sun());
  7.         java.security.Security.insertProviderAt(new com.sun.net.ssl.internal.ssl.Provider(),1);
  8.  
  9.  
  10.         System.setProperty("javax.net.ssl.trustStore", "keystore_filename");
  11.  
  12.         java.security.Provider myprov = java.security.Security.getProvider("SunJSSE");
  13.  
  14.  
  15.     HttpsURLConnection c;
  16.  
  17.         try {
  18.             URL url = new URL ( rptUrl );
  19.             c = (HttpsURLConnection)url.openConnection();
  20.  
  21.             //set cache and request method settings
  22.             c.setUseCaches(false);
  23.  
  24.             //set other headers
  25.             c.setRequestProperty ("Content-Type", "application/pdf");
  26.  
  27.             //connect to the server..
  28.             c.connect();
  29.         }
I have saved the certificate for reference and I assume to I need to tell the program to look at that but this will happen every time there is a new certificate (the program needs to look at different servers), so is there a way to trust-all sites or something to get this to work? I've looked on other forums and they mention this but I'm not clear how to do it exactly.

Changing the HttpURLConnection object to HttpsURLConnection throws up a 'java.lang.ClassCastException' error coz its an abstract class.. Any ideas? Thanks a lot
Jun 5 '07 #1
0 1125

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: Paul Sweeney | last post by:
Does anyone know of a working (python) https proxy which allows viewing of unencrypted data being sent from my browser to an https site? I've worked my way through most on the list at...
22
by: Bloke | last post by:
Hi all. Some time ago (years) I had a script on Python 2.2 that would retieve a HTTPS web site. I used python22-win32-ssl.zip to handle the SSL aspect and it worked wonderfully. I am...
2
by: MarkAurit | last post by:
I have a web service Im using on a machine via http in a dmz that works file. Im now attempting to use it in a second server, this one using https. When I attempt to add the Web Reference in vs.net...
0
by: mahesh anasuri | last post by:
Hi all, I am new to this mailing list. Thankful if any one is using curl/linux version to and worked on Https. I have created certificates (PEM format) for client and server using openSSL. I...
14
by: david | last post by:
I have developed web forms including login by using ASP.NET via HTTP. Now I want to secure the connection from client to the server via HTTPS. How can I configure the server or something else to...
2
by: Greg Wood | last post by:
As a new member, I hope I am posting correctly. Bear with me if not ! I found a posting by Earle Oxner that very closely matches the situation we are in. Sadly, there were no replies to his post,...
0
by: NoaGross | last post by:
Hi, I'm relly new in java and I have a problem. I'm using java applet. When using http all ok, but when trying to use https i get: Java Plug-in 1.5.0_10 Using JRE version 1.5.0_10 Java...
0
by: philipdv | last post by:
I have a process reading xml files over an https connection My code to read this xml file is CErrorAndLog.LogAlways("CKlim", "parseXML", "Parsing XML file: " + strFileName) ...
0
by: Gustavo Rahal | last post by:
Hi I'm trying to build a xmlrpc client that uses a proxy to connect to a xmlrpc server in https. I've googled and came up with a code snippet that doesn't actually work. What is missing?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.