• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.net.UnknownHostException using JSSE

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I�m testing some code and trying to connect to a secure site through JSSE. When connecting I�m finding all the time the same exception: java.net.UnkownHostException.

This is the exception thrown:

java.net.UnknownHostException: www.paypal.com
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.<init>(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.a(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.a(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.a(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)

I�ve configured my keystore and trustore (correctly?) and no complaints about it. I�m behind a proxy, but that�s now ok (I�m authenticating correctly).

The funny thing is that when connecting to a non-secure site the connection works perfectly.

This is my code:

import java.net.*;
import java.io.*;

public class TestSSL{


public MichelSSL(){
try{
System.getProperties().put("proxySet", "true");
System.getProperties().put("proxyHost", "proxysite");
System.getProperties().put("proxyPort", "8080");

Authenticator.setDefault(new MyAuthenticator());


String inputLine;

//URL url = new URL("http://www.verisign.com:443");
URL url = new URL("https://www.paypal.com");
//URL url = new URL("http://www.google.com");
URLConnection conn = url.openConnection();


BufferedReader in = new BufferedReader(
new InputStreamReader(conn.getInputStream()));

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

in.close();

}catch(Exception e){
e.printStackTrace();
}

}

public static void main(String args[]){
TestSSL tp = new TestSSL();
}
}

class MyAuthenticator extends Authenticator{
protected PasswordAuthentication getPasswordAuthentication(){
return new PasswordAuthentication("user", "pass".toCharArray());
}
}

Any ideas what�s going wrong???

All help will be much appreciated.

thanks

Alberto.
reply
    Bookmark Topic Watch Topic
  • New Topic