Joao, You _should_ let HttpClient class handle all the intricacies of establishing connections to the target host instead of using HttpConnection directly. Please refer to the HttpClient tutorial / SSL guide for instructions on how to HttpClient for HTTPS communication.
http://jakarta.apache.org/commons/httpclient/tutorial.html http://jakarta.apache.org/commons/httpclient/sslguide.html Oleg >-- Original Message -- >Reply-To: "Jakarta Commons Users List" <[EMAIL PROTECTED]> >Date: Tue, 17 Feb 2004 13:22:58 +0000 >From: Joao Cerdeira <[EMAIL PROTECTED]> >To: Jakarta Commons Users List <[EMAIL PROTECTED]> >Subject: [HTTPClient] Problems with SSL and PROXY > > >Hi, > >I have a class using the last version of httpclient the build 2.0 > >and i need to make a HTTPS request throuth a proxy. > >*My CODE:* > >Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); > System.setProperty("java.protocol.handler.pkgs", >"com.sun.net.ssl.internal.www.protocol"); > > Protocol myhttps = new Protocol("https", new >SSLProtocolSocketFactory(), 443); > > HttpConnection hc = new HttpConnection("www.multicert.com",443, >myhttps); > hc.setProxyHost("proxy.multicert.inet"); > hc.setProxyPort(8080); > > > try > { > > > hc.open(); > hc.tunnelCreated(); > > GetMethod post = new GetMethod("/"); > > > > System.out.println("code -> " + post.execute(new >HttpState(),hc)); > System.out.println("data -> " + new >String(post.getResponseBodyAsString())); > > } catch (Exception e) > { > e.printStackTrace(); > } > >*MY STACK TRACE:* > >run-client: > [java] java.net.SocketException: Socket closed > [java] at >com.sun.net.ssl.internal.ssl.SSLSocketImpl.a([DashoPro-V1.2-120198]) > [java] at >com.sun.net.ssl.internal.ssl.AppOutputStream.write([DashoPro-V1.2-120198]) > [java] at >org.apache.commons.httpclient.HttpConnection$WrappedOutputStream.write(HttpConnection.java:1368) > [java] at >java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:67) > [java] at >java.io.BufferedOutputStream.flush(BufferedOutputStream.java:125) > [java] at >org.apache.commons.httpclient.HttpConnection.flushRequestOutputStream(HttpConnection.java:799) > [java] at >org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2277) > [java] at >org.apache.commons.httpclient.HttpMethodBase.processRequest(HttpMethodBase.java:2657) > [java] at >org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1093) > [java] at TesteJakarta.main(TesteJakarta.java:43) > > >give me this error. > >Anyone give me a help please. > >NOTE: My proxys supports SSL Tunneling. > >Thanks, > Jo�o Cerdeira > > >-- > >Jo�o Ant�nio Figueira Cerdeira <mailto:[EMAIL PROTECTED]> > > > >[EMAIL PROTECTED] > >Investiga��o, Desenvolvimento e Consultadoria > Gestor de E-Bussiness > >MULTICERT S.A. > > > >http://www.multicert.com/ > >Edif�cio Correios de Portugal - Pra�a da Trindade, 32, 3� Andar > > > >4000-539 Porto - Portugal > > > >Tel: +351 223 391 810 > > > >Fax: +351 223 391 811 > > > > > >--------------------------------------------------------------------- >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]
