Usage of URLConnection in EAR.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Usage of URLConnection in EAR.

Pat0675
This post has NOT been accepted by the mailing list yet.
Hello together,

in my application I have to check the content of a URL. For this purpose I use the URLConnection.
Here is some Code...

        URLConnection crlConnection = url.openConnection();
        crlConnection.setConnectTimeout(1500);
        try (InputStream is = crlConnection.getInputStream()) {
        ........
        }

In come cases the URL is an https url, and for this I want to set my own ssl socket factory.
Like this e.g.

javax.net.ssl.HttpsURLConnection newConnection = (HttpsURLConnection) u.openConnection();
                newConnection.setSSLSocketFactory(sslSF);

And here i got an ClassCastException:

com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl cannot be cast to javax.net.ssl.HttpsURLConnection

How can I do this, or are there any other ways in wildfly?

Thanks in advance.