Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.net.UnknownHostException

843811Apr 17 2006 — edited Jul 11 2006
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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 8 2006
Added on Apr 17 2006
3 comments
1,161 views