我正在尝试从 android 到 api 端点“ https://api_chamakah.ivilleinc.com/ ”的 https 请求。但是,无论我尝试什么选项,我都会得到“通过对等方关闭连接”,来自邮递员和浏览器的请求都可以正常工作。
String webUrl = EndPointMethods.BASE_URL + EndPointMethods.CATEGORIES;
URL url = new URL(webUrl);
HttpsURLConnection urlConnection = (HttpsURLConnection)url.openConnection();
try {
urlConnection.setSSLSocketFactory(new SSLSocketFactoryExtended());
} catch (NoSuchAlgorithmException e) { e.printStackTrace(); }
catch (KeyManagementException e) { e.printStackTrace();}
urlConnection.setRequestMethod("GET");
BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();