0

I use ksoap2 to access a webservice. Everything was just fine before to change the test webservice with production one, witch use a https protocol.

I know that this question was asked few more times here, on stackoverflow, but none of the answers work for me. When I use ksoap2 with https I got this error (exception):

Not trusted server certificate

Someone provided and answer (solution) here: Android ksoap2 via https but I don't understand how to implement that solution (or the proposed solution is not working for me)

The certificate used by WS is a self issued ssl certificate - I use the application only inside a small company, but the company system administrator requires encrypted connection.

Can someone provide a better explanation for this issue?

Thank you.

Community
  • 1
  • 1
Zelter Ady
  • 6,266
  • 12
  • 48
  • 75

1 Answers1

1

I had a similar problem. Basically, when using Http related classes with the https protocol, Android will check with its installed certificates(which I believe are stored in the os keystore).

Because your certificate is self-signed, the certificate is not trusted. I added my self-signed certificate to my app for testing purposes(alexander.egger's answer at How to install trusted CA certificate on Android device?). Maybe you can use this approach? I guess Vedran's approach at Android ksoap2 via https does a similar thing and should work too. What part of that answer is unclear?

However, I dont think these are good solutions.

For my production environment, I ordered a (cheap) ssl certificate from a signing authority trusted by all Android devices and installed it on the server. I am not going to advertise here, but most commercial ssl certificates are trusted by all android devices, and it should be easy to find a cheap one with some research. I think this is the best solution to this problem. Without a proper ssl certificate, your server would be untrusted to the entire world except your particular app, which is probably not a good solution(what if you extend to an ios device, a third party application calling the webservice,etc..).

Community
  • 1
  • 1
Integrating Stuff
  • 5,253
  • 2
  • 33
  • 39
  • My application is an internal application, running on internal employes phones. The only reason I need ssl is because this is the way I got access to the WS - someone else decides so. The solution provided by Vedran is to modify the ksoap library. This is the part I don't understand. I downloaded the source - I cannot load the source as android project in my eclipse. A better question is how to add the source code for ksoap2 to eclipse and to build my own library? – Zelter Ady Aug 19 '12 at 12:47
  • I did not have to build android-ksoap2 myself. The solution I used for testing just extended some classes. Building android-ksoap2 yourself shouldn't be that difficult though. You could check out the project at http://code.google.com/p/ksoap2-android/wiki/SourceCodeHosting, either using git or svn, modifying the necessary source code files, and then running maven clean install. – Integrating Stuff Aug 19 '12 at 12:52
  • I have the source code for the project, under ksoap2-android folder. How do I load the files on Eclipse? I tried to create an "Android projects from existing code" but I didn't succeed. Can you please advice me? – Zelter Ady Aug 19 '12 at 13:04
  • It is setup as a Maven Project, so you should probably install a Maven Eclipse plugin such as m2eclipse(http://www.sonatype.org/m2eclipse/). Once you have installed this plugin, and have restarted Eclipse, you can Import>Maven>Existing Maven projects and then point to the location where the ksoap2-android source resides. The project will then be imported into Eclipse. To build after your modifications, rightclick the project and run Run As>Maven install (or Run As>Maven build->enter "clean install" as goals). This will produce the modified jar. – Integrating Stuff Aug 19 '12 at 13:13