Hi All,
I am new to android.
I have been trying to use httpclient to post data on https (secure).
I have searched all forums of android but I could not find any
solution that works with httpclient on https. I have seen some
solutions using HttpsURLConnection. and SSLContext.
I would like to go with httpclient not URLConnection as I require to
manage cookies and al.
I am looking for your exert advice on above matter.
Thank you very much to all in advance.

I have set <uses-permission
android:name="android.permission.INTERNET" /> tag in
AndroidManifest.xml .
-------here is the log I am getting--------
E/MessageSender(  822): Caught exception
E/MessageSender(  822): javax.net.ssl.SSLException: Not trusted server
certificate
E/MessageSender(  822):   at
org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake
(OpenSSLSocketImpl.java:363)
E/MessageSender(  822):   at
org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl
$SSLInputStream.<init>(OpenSSLSocketImpl.java
:505)
E/MessageSender(  822):   at
org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.getInputStream
(OpenSSLSocketImpl.java:446)
E/MessageSender(  822):   at
org.apache.http.impl.io.SocketInputBuffer.<init>
(SocketInputBuffer.java:93)
E/MessageSender(  822):   at
org.apache.http.impl.SocketHttpClientConnection.createSessionInputBuffer
(SocketHttpClientConnection.
java:83)
E/MessageSender(  822):   at
org.apache.http.impl.conn.DefaultClientConnection.createSessionInputBuffer
(DefaultClientConnection.j
ava:170)
E/MessageSender(  822):   at
org.apache.http.impl.SocketHttpClientConnection.bind
(SocketHttpClientConnection.java:106)
E/MessageSender(  822):   at
org.apache.http.impl.conn.DefaultClientConnection.openCompleted
(DefaultClientConnection.java:129)
E/MessageSender(  822):   at
org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection
(DefaultClientConnectionOper
ator.java:136)
E/MessageSender(  822):   at
org.apache.http.impl.conn.AbstractPoolEntry.open
(AbstractPoolEntry.java:164)
--------------End log-----------

I found solution of defining TrustManager in context but a constructor
SSLSocketFactory(SSLcontext);
available in httpclient version 4.0 but not available on android .

As per some post
I have also created DummySSLSocketFactory  and TrustManager.
but I don't know how to use them with httpclient as

Some Portion of code
 SSLSocketFactory sslSocketFactory =  SSLSocketFactory.getSocketFactory
();
sslSocketFactory.setHostnameVerifier
(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
   supportedSchemes.register(new Scheme("https", sslSocketFactory,
443));


SSLContext context = null;
        try {
            context = SSLContext.getInstance("TLS");
            context.init(
              null,
              new TrustManager[] {new _FakeX509TrustManager()},
              null);
        } catch (Exception e) {
            trace.log(Level.SEVERE, e.getMessage(), e);
            //throw new HttpClientError(e.toString());
            // TODO throw a more appropriate exception
            throw new RuntimeException(e.toString());
        }

I have also tried one suggested by bala on
http://www.android-portal.com/2007/12/20/secure-server-socket-with-tlsssl-on-android-fails/
but that one is not for httpclient.

Once again thanks to all in advance.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to