Could you list your operating environment. I have (see my other note) a
very similar problem, and I think that by working out which components
are common to both of us we can narrow this down much quicker.
I am using 5.0.27 Tomcat (I also used 4.1 and got the same problem), I am
using JSPs with JSTL and the IO taglib, I am running on Sun JVM 1.4.2_05
(also tried 1.4.1) on a Linux system. As you are not using JSPs etc that
just about leaves Tomcat itself, JVM and the operating system.
David
On Monday 26 July 2004 19:15, Honey George wrote:
> Hi All,
> I am facing a problem with HttpUrlConnection in
> Tomcat. I wanted to extract the contents of an https
> enabled URL,
> actually from the same site where my application is
> running(Will not try to access external URLs). My
> program will look
> like this.
>
> ===========================================================================
>======================================= import java.net.*;
> import java.util.*;
> import java.io.*;
>
> import javax.net.ssl.HostnameVerifier;
> import javax.net.ssl.HttpsURLConnection;
> import javax.net.ssl.SSLSession;
> import javax.net.ssl.*;
> .............
>
> System.getProperty("java.protocol.handler.pkgs","javax.net.ssl");
> java.security.Security.addProvider(new
> com.sun.net.ssl.internal.ssl.Provider());
> .................
> HostnameVerifier hv = new HostnameVerifier()
> {
> public boolean verify(String urlHostName,
> SSLSession session)
> {
> System.out.println("Warning: URL Host:
> "+urlHostName+" vs. "+session.getPeerHost());
> return true;
> }
> };
>
> HttpsURLConnection.setDefaultHostnameVerifier(hv);
>
> // Create a trust manager that does not
> validate certificate chains
> TrustManager[] trustAllCerts = new
> TrustManager[]{
> new X509TrustManager() {
> public
> java.security.cert.X509Certificate[]
> getAcceptedIssuers() {
> return null;
> }
> public void checkClientTrusted(
> java.security.cert.X509Certificate[]
> certs, String authType) {
> }
> public void checkServerTrusted(
> java.security.cert.X509Certificate[]
> certs, String authType) {
> }
> }
> };
>
> // Install the all-trusting trust manager
> try
> {
> SSLContext sc =
> SSLContext.getInstance("SSL");
> sc.init(null, trustAllCerts, new
> java.security.SecureRandom());
>
> HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
> } catch (Exception e) {
>
> }
>
> ................................
>
> HttpURLConnection httpCon =
> (HttpURLConnection) new
> java.net.URL("https://www.abc.com/test.txt").openConnection();
>
> httpCon.setRequestProperty(USER_AGENT_HEADER_FIELD,
> "");
>
> httpCon.setRequestProperty(ACCEPT_HEADER_FIELD,
> "text/plain");
> return httpCon;
>
> InputStream is = httpCon.getInputStream();
> ===========================================================================
>======================================= Here the problem is that the
> InputStream does not
> return any contents when executed from inside Tomcat.
> But I am able to
> extract the contents of the URL when I execute outside
> tomcat in a command line program. The Connection
> object returned
> by "new java.net.URL("https://www.abc.com/test.txt")"
> is sun.net.www.protocol.https.HttpsURLConnectionImpl.
>
> Can I get some help on this one?
>
> Thanks & Regards,
> George
>
>
>
>
>
>
> ___________________________________________________________ALL-NEW Yahoo!
> Messenger - all new features - even more fun!
> http://www.allnewmessenger.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]