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!

Communicating with HTTPS server with Client Authentication

843811Mar 22 2004 — edited Dec 30 2007
Hi,

I need to do a Client Authentication with the server running on HTTPS (from a Java code).

First, I thought of connecting and reading to a HTTPS server and try Client Authentication later.

I failed in the first step itself. I could not connect to https://mail.yahoo.com . It throws an the following error..
NOTE: I could get the connection and read the content of the server running my company's internal network using the below code.

Please let me know if you guys have any idead about this one and also for doing the Client Authentication

java.util.NoSuchElementException
at java.util.StringTokenizer.nextToken(StringTokenizer.java:232)
at sun.net.www.protocol.http.HttpURLConnection.doTunneling(HttpURLConnection.java:768)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(DashoA6275)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:562)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(DashoA6275)
at Test.main(Test.java:19)
Exception in thread "main"



import java.io.*;
import java.net.*;
import javax.net.ssl.*;

public class Test {
public static void main(String args[]) throws Exception {



System.setProperty("https.proxyHost", "ghqproxy1.is.ge.com");
System.setProperty("https.proxyPort", "80");

URL url = new URL("https://www.entrust.com/");
URLConnection conn = url.openConnection();
HttpsURLConnection urlConn = (HttpsURLConnection) conn;
BufferedReader in = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));

String str;
while( (str=in.readLine()) != null) {
System.out.println(str);
}
}
}

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 26 2008
Added on Mar 22 2004
35 comments
2,880 views