我正在更新android应用程序的Web服务URL,我们正在使用https协议.我看到我当前的https网址正在运行,但现在我们正在迁移到新域,然后它正在创建问题.
我在stackoverflow上检查了许多线程,如javax.net.ssl.SSLException:证书中的主机名与android不匹配,但没有找到任何好的答案,主要是回答绕过此安全或允许所有.
javax.net.ssl.SSLException:证书中的主机名不匹配:
//HttpGet getMethod = new HttpGet(String.format(httpURL));
HttpGet getMethod = new HttpGet(httpURL);
DefaultHttpClient client = new DefaultHttpClient();
ResponseHandler<String> responseHandler = new BasicResponseHandler();
HttpParams params = client.getParams();
params.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 60000);
params.setParameter(CoreConnectionPNames.SO_TIMEOUT, 60000);
client.setParams(params);
responseBody = client.execute(getMethod, responseHandler);
responseBody = responseBody.trim();
Run Code Online (Sandbox Code Playgroud)
提前致谢.