Using java class HttpsURLConnection
Posted
by KB22
on Stack Overflow
See other posts from Stack Overflow
or by KB22
Published on 2010-06-14T14:24:25Z
Indexed on
2010/06/14
14:32 UTC
Read the original article
Hit count: 254
Hi all,
I have a small piece of code which basically impements a HTTP-Client, i.e. it POSTS request and works with re RESPONSE. As long as HTTP is concenerned everthing work well. For some reason I now have to support HTTPS too. So here is briefly what I do in order to get a connection opened:
URL url = new URL(serverAddress);
HttpsURLConnection httpsConn = (HttpsURLConnection) url.openConnection();
This fails, stating:
sun.net.www.protocol.https.HttpsURLConnectionImpl cannot be cast to com.sun.net.ssl.HttpsURLConnection
I guess this is kinda trivial, but I just don't get what I'm doing wrong in this one... Googled it, and the code just looks right - not?
any ideas are appreciated!
thanks,
K
© Stack Overflow or respective owner