Ok, here is some more information. I see that the peerPrincipal in the SSLSession passed into used in the HostnameVerifier changes sometimes from my hostname certificate (CN=*.<OurHostName>.com, OU=Domain Control Validated) to the hosting partner's website (CN=*.webfaction.com,OU=Domain Control Validated - RapisSSL…..)
So it seems that for some reason the peer principal changes and causes the “Hostname <ourHostName> was not verified” exception. One way I have been able to reproduce it by disconnecting my router from WAN for sometime (Doesnt always happen but happens 80% of the time). So is there a way to renew the SSLSession or any other workaround? — Thanks Pankaj On March 13, 2014 at 5:57:33 PM, Pankaj Chawla ([email protected]) wrote: Hi I have a strange situation at hand. I have a webapi running on a server with a valid SSL certificate (bought from Go Daddy). While the connection works perfectly for extended periods of time (10-15 hours) and my app is able to get data over https, for some strange reason after 10-15 hours the HttpsURLConnection starts throwing IOExceptions with ‘Hostname <servername> was not verified’ message. The IOException will keep happening till I restart the app. Below is the outline of the code that I am using. Has anybody faced a similar problem? It seems like a SSL handshaking issue but I am not able to figure out why it would come 10-15 hours later and go away with an app restart. While the app is raising exceptions, I can switch to the browser and access the same https url with no issue. URL url = null; HttpsURLConnection urlc = null; try { url = new URL(“https://test.example.com/webapi"); urlc = (HttpsURLConnection) url.openConnection(); urlc.setRequestProperty("Connection", "close"); urlc.setConnectTimeout(15000); urlc.setReadTimeout(10000); urlc.connect(); if (urlc.getResponseCode() == 200) { // Good response mCloudAlive = true; Log.d("CLOUDSTATUS", "*internet connection to server found* ".concat(urlc.getResponseMessage())); NotificationHandler.setCloudConnectionStatus(true); } else { mCloudAlive = false; Log.d("CLOUDSTATUS", "internet connection to server error ".concat(urlc.getResponseMessage())); NotificationHandler.setCloudConnectionStatus(false); } } catch (IOException e) { mCloudAlive = false; Log.d("CLOUDSTATUS", "server io exception ".concat(e.getMessage())); NotificationHandler.setCloudConnectionStatus(false); } finally { urlc.disconnect(); } — Thanks Pankaj -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

