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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

ClassCastException..trying to use HttpsURLConnection

843811May 9 2003 — edited May 27 2003
Hi, I'm trying to make an HTTPS connection using

[marc@blueprint-14 marc]$ java -version
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)

on Redhat 9.

No matter what i do, I can never get an HttpsURLConnection, it's always an HttpURLConnection.

Any help would be appreciated.


public static void main(String a[]) throws Exception {
System.setProperty("java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.www.protocol");
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

URL url = new URL("https://www.verisign.com:443");
URLConnection con = url.openConnection();

if(con instanceof HttpsURLConnection) {
System.out.println("https");
} else if(con instanceof HttpURLConnection) {
System.out.println("http");
}

}

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jun 24 2003
Added on May 9 2003
7 comments
21,890 views