जब मैं एक HTTPS कनेक्शन मैं SSL अपवाद मिल खोलना चाहते हैं। इस अपवाद के प्रति संवेदनशील नहीं होने के लिए HttpURLConnection को कैसे सेट करें?HTTPS कनेक्शन के SSL प्रमाणपत्र सत्यापन को अक्षम करें?
मेरे कोड है:
private String getData() {
String response = null;
String connection = "https://www.kamalan.com/";
try {
URL url = new URL(connection);
Log.i(TAG, "Try to open: " + connection);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
int responseCode = conn.getResponseCode();
Log.i(TAG, "Response code is: " + responseCode);
if (responseCode == HttpURLConnection.HTTP_OK) {
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
if (in != null) {
StringBuilder strBuilder = new StringBuilder();
int ch = 0;
while ((ch = in.read()) != -1)
strBuilder.append((char) ch);
// get returned message and show it
response = strBuilder.toString();
Log.i("JSON returned by server:", response);
}
in.close();
} else {
Log.e(TAG, "Couldn't open connection in getResepiItems()");
}
} catch (SSLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return response;
}
logcat क्या कहता है सेट के लिए नीचे दी गई विधि? –
@ मॉरिसन चांग यह लॉग बिल्ली में त्रुटि है: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: प्रमाणीकरण पथ के लिए ट्रस्ट एंकर नहीं मिला। –
क्या आपको यह SO पोस्ट दिखाई देता है: http: //stackoverflow.com/questions/6825226/trust-anchor-not-found-for-android-ssl-connection? –