Solved

https: Unable to find valid certification path to requested target

Posted on 2012-03-14
10
618 Views
Last Modified: 2012-03-15
To connect to an https domain I use the following code:
      //uri is a string containing the server https domain address
      URL urlGift = new URL("https://" + uri + ":443/process.cgi");
      HttpsURLConnection conn = (HttpsURLConnection) urlGift.openConnection();
      conn.setDoOutput(true);
      OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
      wr.write(data);
      wr.flush();

      // Get the response
      BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
      String res = "";
      String line;
      while ( (line = rd.readLine()) != null) {
        res += line;
      }
      rd.close();
      return res;
--------
If I add our certificate (.cer) to my cacerts it works fine, but I'm assuming that since our certificate was signed by GoDaddy (up there must reach a CA that presumably is in my cacerts). Nevertheless I keep getting this error:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.: unable to find valid certification path to requested target.
I'm thinking that this is not very different from having a self-signed certificate. One it expires we will have to add the new one to cacerts and distribute it to 100's of users, which is what we want to avoid.
In short, I want to know why the connection is not able to go "up the chain" of certificates to trust the certificate we have.
I know I can create my own trust manager and accept whatever I want. But then what's the point of having a signed certificate by a CA?
Any takers?
0
Comment
Question by:RNMisrahi
  • 5
  • 4
10 Comments
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
In short, I want to know why the connection is not able to go "up the chain" of certificates to trust the certificate we have.

Possibly because you haven't added ALL the certs required to form that chain. Check with GoDaddy as to what you should be doing with what they supply
0
 
LVL 7

Expert Comment

by:gudii9
Comment Utility
check following interesting explanation, link

http://www.java-samples.com/showtutorial.php?tutorialid=210
0
 

Author Comment

by:RNMisrahi
Comment Utility
Thanks CEHJ.
I understand what you're saying, but the way I understand it, we shouldn't need to have the whole chain of trust in our cacerts but only the root certificate. Just as a browser will trust Certificate A if it was signed by Certificate B, which was signed by Certificate C, which I trust because it's in my list of trusted certificates. I.e. a browser doesn't have the chain of every certificate. It'd be an enormous list.
In our case, our certificate is signed by:
GeoTrus DV SSL which is signed by GeoTrust Global CA.

I find it very strange that I have to add any of these intermediate certificates. Again, a browser does recognize it as a safe server because as far as I understand, the chain leads to one of the trusted certificates. Moreover, I have a C# and a Delphi application that communicate with this same site and it doesn't require me to add anything.
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
Is that your server you're trying to connect to?
0
 

Author Comment

by:RNMisrahi
Comment Utility
Yes, this is my server. We have a few hundred users. We used to have a certificate of a different type that's expiring soon.
So we bought this certificate that has a path from GeoTrust Global to GeoTrust DV SSL to our actual certificate.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:RNMisrahi
Comment Utility
Hi CEHJ,

I've listed the cacerts and I can see there what's expected:

The original cacerts (before I import anything) has the GeoTrust Global CA but NOT the GeoTrust DV SSL.
Our certificate is signed by GeoTrust DV SSL, which is signed by GeoTrust Global CA.
Again, I would expect Java to "see" our certificate, signed by DV SSL, which signed by Global CA, which is on our cacerts.

It doesn't surprise me that when I add DV SSL to cacerts our certificate is accepted, since DV SSL signs our certificate. This is as if Java is able to only one step up the chain!

There must be a way to tell HttpsURLConnection to keep going up the chain more than one step.
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
http://support.godaddy.com/help/article/5239 shows something similar to what i guessed: no fewer than 4 certs needing to be imported
0
 

Author Comment

by:RNMisrahi
Comment Utility
CEHJ, could you expand a bit on this?

What does it mean in practice:
Do we need to change the cacerts of our users when the Secondary Certificate (DV SSL) expires? Why can't we rely on the Primary (Global CA) which expires in 20 years?

And so we understand:
Why a browser can go up the chain of signed certificates to the root and Java can go only one certificate up?

I'm ready to assign all points as soon as we get an answer.

Thanks
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
Comment Utility
My guess for the first question is yes. But you need to check with GoDaddy. You need to understand that i work for free here, which is one thing, but quite another to be working for free for GoDaddy too (i assume you paid them for this certification?)

The answer to the last question (and by extension to the one preceding it) is that browsers are probably able to import chains whereas java is able only to work on single entities
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
:)
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
sumDigits  challenge 7 60
array6 challenfge 6 62
base64 decode encode 12 96
Requested array size exceeds VM limit 3 44
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now