?
Solved

Connect to https site

Posted on 2002-07-23
4
Medium Priority
?
453 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 400 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses
Course of the Month10 days, 8 hours left to enroll

765 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