SSL client authentication

by telematics » Thu, 12 Mar 2009 05:40:52 GMT

Sponsored Links
  am new on SSL programming. The Android app I am developing needs to
open an SSL socket to a secure server which requires the client
authentication. When running on the Emulator and trying to talk to a
Server running on the host PC, the following Android code snippet
always gives me a SocketException at the line, SSLSocket c =
(SSLSocket) f.createSocket(hostName, 8888) :

private void openSslClient(String hostName)
KeyStore keyStore = KeyStore.getInstance
InputStream fis = this.getAssets().open("client.bks");
keyStore.load(fis, "clientjks".toCharArray());

KeyManagerFactory kmf = KeyManagerFactory.getInstance

kmf.init(keyStore, "clientkey".toCharArray());

TrustManagerFactory tmf = TrustManagerFactory.getInstance


SSLContext sc = SSLContext.getInstance("TLS");
sc.init(kmf.getKeyManagers(), tmf.getTrustManagers(),
new SecureRandom());

SSLSocketFactory f = sc.getSocketFactory();
SSLSocket c = (SSLSocket) f.createSocket(hostName, 8888);
w = new BufferedWriter(new OutputStreamWriter
r = new BufferedReader(new InputStreamReader
} catch (Exception e)
Log.e(LOG_TAG, "openSslClient failed", e);

The stack trace looks like below:
03-11 21:24:00.585: ERROR/OSNetworkSystem(1093): unknown socket error
03-11 21:24:07.156: ERROR/PatientDataUploader(1093): openSslClient
03-11 21:24:07.156: ERROR/PatientDataUploader(1093): unknown error
03-11 21:24:07.156: ERROR/PatientDataUploader(1093): at
(Native Method)
03-11 21:24:07.156: ERROR/PatientDataUploader(1093): at
03-11 21:24:07.156: ERROR/PatientDataUploader(1093): at
03-11 21:24:07.156: ERROR/PatientDataUploader(1093): at
03-11 21:24:07.156: ERROR/PatientDataUploader(1093): at<init>(
03-11 21:24:07.156: ERROR/PatientDataUploader(1093): at<init>(
03-11 21:24:07.156: ERROR/PatientDataUploader(1093): at
03-11 21:24:07.156: ERROR/PatientDataUploader(1093): at

The server test program I am using is a modified version of
SslReverseEchoer available on Dr. Herong Yang's website. It looks like

public static void main(String[] args) {
if (args.length < 3) {
.println(" java
SslReverseEchoerRevised ksName ksPass ctPass

SSL client authentication

by telematics » Thu, 12 Mar 2009 13:59:14 GMT

 ever mind. I figured it out by my own - add the following to the

<uses-permission android:name="android.permission.INTERNET" />

On Mar 11, 4:40pm, telematics <> wrote:

Sponsored Links

Other Threads

1. android file permissions on the G1

So I bought a G1 and everthing was awesome until today.  Sometime
today one of the apps from the market screwed my environment up Yes, I
know this sounds crazy but hear me out.  So I decided to use my camera
today and when I opened the camera app, It says "please insert an SD
card before using the camera".  I have a 16 GB micro sd card in the
camera.  And before anyone mentions it, my phone was not plugged into
anything at the time.  So I then used the settings app to eject the
card.  I reinserted the card and tried again. Same problem.  When I do
the the sdcard settings, it says that my 16 GB card is mounted and
that there is 10 GB still available.  So then I rebooted the phone.
Tried the camera again.  Same problem.  So then I decided to hit up
the terminal emulator and see what is going on.

I type "ls -l" and this is the file permissions on the sdcard
directory: d---rwxrwx     system system   1969-12-31 19:00  sdcard

when I run chmod 777 sdcard I get "unable to chmod sdcard: Read-only
file system".  Any ideas on how to fix this.  I seem to be constrained
in that I cannot sudo to root.  Is there a way I can fix this without
having to reset my whole phone?

2. GPS wakes up when screen wakes up

I have a properly functioning service that registers a
locationlistener for GPS updates.  It's registered to wake up every 30
mins (even if the object moved 0 meters).

The problem is that everytime the screen wakes up (from standby), it
fires the onStatusChanged, followed by onLocationChanged regardless
how much time has passed since the last GPS fix.

Also, my LocationManager registers this in service's onCreate() and
removes it on onDestoy() and I'm not destroying and re-creating my

Any ideas why would LocationListener's callbacks wake up outside its
scheduled time?


3. ksoftirqd CPU load is too high during video playback

4. android by example

5. keytool - need help

6. Send Bitmap with Socket

7. Assisted GPS