0

I only want to send an html form by post method to a https resource from an Android activity. I have (only for development and testing) an Lighttpd server with it own certificate to make handshaking, so there MUST happen authentication at least from server (client authentication is optional but desirable). I have seen, lots of forums with different ways to make it, but I am a little confused, I do not know which could be the correct way to make it. Please show me a chunk of code. Thank you very very much.

Israel
  • 2,852
  • 4
  • 32
  • 51

2 Answers2

2

Try out this tutorial, it shows GET, POST and Multipart POST request on the android platform http://www.softwarepassion.com/android-series-get-post-and-multipart-post-requests/

Kris
  • 5,465
  • 2
  • 25
  • 45
  • @user2669556 Thank you very much for your repsonse. In this link, there is explained very well how to use POST and GET methods for HTTP, but there is no explanation for how to use HTTPS. Do you have another idea or reference? – Israel Feb 07 '11 at 23:08
1

I wrote some code to submit an HTML form to a server over https, which can be found in this answer. The version in the answer uses an HttpsUrlConnection, and the version in the question uses HttpClient. I could never quite get the right result from the server with the HttpClient version, but either approach should work in theory.

Community
  • 1
  • 1
dave.c
  • 10,862
  • 5
  • 36
  • 61
  • Thank you Dave for your response. I have checked your link but there use InputStreams and OutoutStreams, and I do not need to use connections at this low level. In this [post](http://blog.antoine.li/index.php/2010/10/android-trusting-ssl-certificates/) there is an excelent example but in execution there is an javax.net.ssl.SSLException: Not trusted server certificate. – Israel Feb 07 '11 at 23:21
  • @NeoRiddle I've not had to set up my own keystore as the site I'm connecting to has a cert that is already trusted. Sorry, but I can't really advise you in that area. – dave.c Feb 07 '11 at 23:31