This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Accessing HTTPS URL through SSL - fails with UnknownHostException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Accessing HTTPS URL through SSL - fails with UnknownHostException" Watch "Accessing HTTPS URL through SSL - fails with UnknownHostException" New topic
Author

Accessing HTTPS URL through SSL - fails with UnknownHostException

Raj Shan
Ranch Hand

Joined: Sep 04, 2006
Posts: 65
Hi,

I am trying to access HTTPS URL through SSL. Below is my code. But it continuously throw UnknownHostException. Can someone help me out with this?

import java.net.URL;
import java.net.URLConnection;
import java.security.Security;

public class TestSSL {
public static void main(String[] args) {
System.getProperties().put("http.proxyHost", "XXX");
System.getProperties().put("http.proxyPort", "XXX");
System.out.println("bfr");
System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");
System.out.println("1");
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
System.out.println("2");
try {


//System.getProperties().put("java.protocol.handler.pkgs", "HTTPClient");
//URL url = new URL("https://www.verisign.com/");



URL url = new URL("https://www.verisign.com/");
System.out.println("3");
URLConnection con = url.openConnection();
System.out.println("4");
con.connect();
//java.io.InputStream urlfs = con.getInputStream();
System.out.println("5");
System.out.println("Successful Connection Establishment");

} catch (Exception e) {
System.out.println("Print Exception Details =>"+e.toString());
}

}
}
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Presumably your real code doesn't have

System.getProperties().put("http.proxyHost", "XXX");

but the real proxy host name? If so, have you absolutely confirmed that it's correct?


[Jess in Action][AskingGoodQuestions]
Raj Shan
Ranch Hand

Joined: Sep 04, 2006
Posts: 65
I do have it in my real code. I tried setting my username and password as well. But no use.
Raj Shan
Ranch Hand

Joined: Sep 04, 2006
Posts: 65
This has been fixed by setting

System.getProperties().put("https.proxyHost", "XXX");
System.getProperties().put("https.proxyPort", "XXX");


instead of

System.getProperties().put("http.proxyHost", "XXX");
System.getProperties().put("http.proxyPort", "XXX");

Thanks,
Raj
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing HTTPS URL through SSL - fails with UnknownHostException
 
Similar Threads
Working with HttpsURLConnection
problem accessing https through ssl connection
Help! App using JSSE 1.0.2 freezes
java.net.UnknownHostException using JSSE
how to read files from internet