Hi, I am new to Android. For an application, I need to upgrade a plain TCP socket to SSL socket (server mode) on Android. The following code worked, but it took about 12 seconds to finish the SSL handshake on Samsung Galaxy S with Android 2.3.3 (API 10). I also tested the same code on simulator with android 4.0.3 (API 15), the result was same. The client was Chrome browser. From the Wireshark trace, all the SSL handshake messages flowed very fast, and then there was a 10 seconds gap between the Change Cipher Spec/Encrypted Handshake message (last two messages of SSL handshake on server side) and the first application Data (it was HTTP GET from chrome).
private boolean handleSSLHandshake() { try { SSLContext sc = SSLContext.getInstance("TLS"); sc.init(this.kmf.getKeyManagers(), null, null); SSLSocketFactory factory = sc.getSocketFactory(); this.sslSocket = (SSLSocket) factory.createSocket(this.socket, this.socket.getInetAddress().getHostAddress(), this.socket.getPort(), true); this.sslSocket.setUseClientMode(false); this.sslSocket.addHandshakeCompletedListener(this); this.sslSocket.startHandshake(); Log.d(TAG, "SSL upgrade succeeds!"); this.input = this.sslSocket.getInputStream(); this.output = this.sslSocket.getOutputStream(); } catch (NoSuchAlgorithmException e) { Log.d(TAG, "Got NoSuchAlgorithmException while upgrading to SSL" + e); this.sslSocket = null; return false; } catch (KeyManagementException e) { Log.d(TAG, "Got KeyManagementException while upgrading to SSL" + e); } catch (UnknownHostException e) { Log.d(TAG, "Got UnknownHostException while upgrading to SSL" + e); this.sslSocket = null; return false; } catch (IOException e) { Log.d(TAG, "Got IOException while upgrading to SSL" + e); this.sslSocket = null; return false; } return true; } Does anyone have clue on which code took 10 seconds? How to reduce this? And how to debug the SSL handshake on Android? Thanks a lot for help, /Kaiduan -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en