Solved

Connect to https site

Posted on 2002-07-23
4
452 Views
Last Modified: 2010-03-31
I want to connect to Https site, for this sample code,when connec to https://www.verisign.com everything is alright. But when I wanna to connect to another https(example, https://www.ep.com.my), I get an exception saying
Exception in thread "main" javax.net.ssl.SSLHandshakeException: Could not find trusted certificate.

how to solve this problem. URGENT. thankss

public class Test {
    public static void main(String[] args) throws Exception {
     URL site = new URL("https://www.verisign.com/");    
     BufferedReader in = new BufferedReader(
                    new InputStreamReader(
                    site.openStream()));

     String inputLine;

     while ((inputLine = in.readLine()) != null)
         System.out.println(inputLine);

     in.close();
    }
}
0
Comment
Question by:cHEo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 4

Accepted Solution

by:
antons061400 earned 100 total points
ID: 7173508
0
 

Expert Comment

by:hi_billy
ID: 7213829
i think you are using older version of JDK....right?....
if you want to make a connection to https site, you must import the JSSE package(http://java.sun.com/products/jsse/). and modify your code like this :


import javax.net.ssl.*;
import any.other.package;

public class Test {
   public static void main(String[] args) throws Exception {
System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");

java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

    URL site = new URL("https://www.verisign.com/");    
    BufferedReader in = new BufferedReader(
                   new InputStreamReader(
                   site.openStream()));

    String inputLine;

    while ((inputLine = in.readLine()) != null)
        System.out.println(inputLine);

    in.close();
   }
}



hopes this help...:-)
0
 
LVL 35

Expert Comment

by:girionis
ID: 8951730
No comment has been added lately, so it's time to clean up this TA.

I will leave a recommendation in the Cleanup topic area that this question is:

- points to antons

Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

girionis
Cleanup Volunteer
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video teaches viewers about errors in exception handling.

717 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