A few days ago, I updated my application engine server to work only with secure HTTP requests (HTTPS). (adding the line "secure: always" in the app.yaml file).
Everything works fine, I manage to get a response from my application engine server with my application (it works on android 4.1.2), but today I found out that on devices 4.4.2 I get the following error:
06-04 20:11:29.501: W/System.err(21158): javax.net.ssl.SSLPeerUnverifiedException: No peer certificate 06-04 20:11:29.504: W/System.err(21158): at com.android.org.conscrypt.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:146) 06-04 20:11:29.505: W/System.err(21158): at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:93) 06-04 20:11:29.505: W/System.err(21158): at org.apache.http.conn.ssl.SSLSocketFactory.createSocket(SSLSocketFactory.java:388) 06-04 20:11:29.505: W/System.err(21158): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:165) 06-04 20:11:29.506: W/System.err(21158): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164) 06-04 20:11:29.506: W/System.err(21158): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119) 06-04 20:11:29.506: W/System.err(21158): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360) 06-04 20:11:29.507: W/System.err(21158): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555) 06-04 20:11:29.507: W/System.err(21158): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487) 06-04 20:11:29.507: W/System.err(21158): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
This is the code in the client responsible for sending json with the http mail request:
static private String getJson(String json,String url){ HttpClient httpClient = new DefaultHttpClient(); String responseString=""; try { HttpPost request = new HttpPost("https://XXXXXX.appspot.com/XXXX/XXXX"); StringEntity params =new StringEntity(json, "UTF-8"); request.addHeader("content-type", "application/json"); request.setEntity(params); HttpResponse response = httpClient.execute(request); HttpEntity entity = response.getEntity(); responseString = EntityUtils.toString(entity, "UTF-8"); }catch (Exception ex) { ex.printStackTrace();
I suspect that in this way I am making HTTP requests, it is somewhat mistaken in new devices (this is the only reason I can think of, as it works fine on my device, but on a new device it is not)
I also tried to create my HttpClient object using this method (which I saw sometimes fixes the problem), but this did not help:
static private HttpClient createHttpClient() { HttpParams params = new BasicHttpParams(); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET); HttpProtocolParams.setUseExpectContinue(params, true); SchemeRegistry schReg = new SchemeRegistry(); schReg.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); schReg.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443)); ClientConnectionManager conMgr = new ThreadSafeClientConnManager(params, schReg); return new DefaultHttpClient(conMgr, params); }
It has been browsing the entire Internet for about 8 hours, but there is no solution.
Thanks for the helpers.