hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marki <puto.c...@gmail.com>
Subject FileUpload Example + SSL
Date Tue, 20 May 2008 11:51:07 GMT
Hi there,newbie here!
This is my first mail the list.

Im working on a httpCliente capable to send files to a servlets.

Thanks to the FileUpload Example what i found in:
http://svn.apache.org/viewvc/httpcomponents/oac.hc3x/trunk/src/examples/
-100 %recommended-
 I success sending files to the servlet.

The problem i actually hace is that, the file sending must be done over SSH.

My server is apache Tomcat and i configure it to accept https calls.
Following apache instrucctions I create a .ketStore file,

Then I make a test program to assure I reach the server throght SSH:

    private static int port = 8443;             // The HTTPS Port (usually
443)
    private static String host = "localhost";   // The server to connect to
    private static String path = "/WebEFX/hello";// The file/path to
retrieve

System.setProperty("javax.net.ssl.trustStore", "C:\\Documents and
Settings\\myUser\\.keystore");
System.setProperty("javax.net.ssl.trustStorePassword",  "changeit");

Security.addProvider(new
com.sun.net.ssl.internal.ssl.Provider());
// Connect to the server using an SSL socket
SSLSocketFactory factory = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket socket = (SSLSocket) factory.createSocket(host, port);

// Send HTTP GET message
            PrintWriter out = new PrintWriter(new
BufferedOutputStream(socket.getOutputStream()));
            out.println("GET "+path+" HTTP/1.1");
            out.println("Host: "+host);
            out.println("Connection: close");
            out.println("User-Agent: Java HTTPS Client");
            out.println("");
            out.flush();

            // Now dump server reply to console
            BufferedReader in = new BufferedReader(new
InputStreamReader(socket.getInputStream()));
            int c;
            while ((c = in.read()) != -1)
            {
                System.out.write(c);
            }

            // All done, close io streams and socket
            out.close();
            in.close();
            socket.close();

It works fine.
what i want to do is, add SSH support to the FileUpload example basicly.
I have checket out the SSL Guide in httpClient's Web but I dont know hoy to
deal with my actual ".keyStore" and my "changeit" password.
How can I merge these two things??

Thanks in advance for the advice!!!

-- 
Regards

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message