Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSL Client on Android

I'm currently writing a client part for Android (2.2) and a server using SSL. I managed to exchange messages between the server and a normal client, but Android doesn't seem to be too happy about self signed certificates. I've searched Stackoverflow and Googled A LOT and LOTS of people are having similar problems. All the answers I've found so far either wasn't working or didn't make any sense. Most of the code samples out there are for HTTPS, but this I cannot use, as I need to communicate through a socket (SSLSocket is my best guess). I've tried lots of different code, but right now I'm kinda back at zero again.

So far I've figured out that I have to create a certificate (think I got that right) and a custom TrustManager. Obviously I haven't been able to find any working code, which is why I ask here, as there usually are some really helpful people.

I'm looking for a detailed description of what is supposed to be done, and some code, which can be made into a working Android client code.

Thanks in advance

like image 917
Casper Avatar asked Mar 28 '11 12:03

Casper


People also ask

How do I enable SSL on my Android?

From Credential Storage Tab, click on Install from Phone Storage/Install from SD Card. A new file storage manager will appear. Now find the SSL certificate from your device. If it asks to enter the PKCS#12 password, add that password which was generated during SSL download process.

Do Android apps use SSL?

Mobile apps, just like websites, use the same method to secure communications—SSL/TLS. However, SSL certificate validation is not trivial.

What is SSL library in Android?

The Secure Sockets Layer (SSL)—now technically known as Transport Layer Security (TLS)—is a common building block for encrypted communications between clients and servers. It's possible that an application might use SSL incorrectly such that malicious entities may be able to intercept an app's data over the network.


1 Answers

I have done it with porting native android browser. I just changed how ssl context is created. I promised that I will also put some working example on SandroB site but... :)

https://market.android.com/details?id=org.sandrob

http://code.google.com/p/sandrob/source/browse/misc/examples/HttpsConnection.java

like image 75
SandroB Avatar answered Oct 01 '22 10:10

SandroB