I am also looking for an SSL httpclient example for android, especially on how to import the certificate.
-- leo On Sat, Nov 21, 2009 at 1:19 AM, androidguy <[email protected]> wrote: > Hi Experts, > any luck for help? > In nutshell, > People suggested two ways to do it > 1)set context in httpconnection with custom TrustManager > 2)Set TrustManager some other way . > > in android org.apache.http.conn.ssl.SSLSocketFactory > SSLSocketFactory(SSLContext sslContext) method is not available. > see > > http://hc.apache.org/httpcomponents-client/httpclient/apidocs/org/apache/http/conn/ssl/SSLSocketFactory.html > and > > and > > http://developer.android.com/reference/org/apache/http/conn/ssl/SSLSocketFactory.html > > any help? > Thanks, > AndroidGuy > On Nov 18, 12:18 am, androidguy <[email protected]> wrote: > > 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 onhttp:// > www.android-portal.com/2007/12/20/secure-server-socket-with-tl... > > 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 [email protected] > To unsubscribe from this group, send email to > [email protected]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

