当我的应用尝试连接互联网时,我收到以下错误消息。原因是设备上的日期时间配置不正确。
堆栈追踪:
javax.net.ssl.SSLHandshakeException: Unacceptable certificate: CN = COMODO ECC Domain Validation Secure Server CA 2, O = COMODO CA Limited, L = Salford, ST = Greater Manchester, C = GB
以下是我用来连接的代码。我想连接互联网而不强迫用户更改日期时间。可能吗 ?如果可能的话,如果有人帮助我,我将不胜感激。
URL url = new URL(link);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.setRequestProperty("User-Agent", "");
connection.setRequestMethod("GET");
connection.connect();
InputStream is;
if (connection.getResponseCode() >= 400) {
is = connection.getErrorStream();
} else {
is = connection.getInputStream();
}
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
sb.append(reader.readLine()).append("\n");
String line = "0";
while ((line = reader.readLine()) != null) {
sb.append(line).append("\n");
}
is.close();
result = sb.toString();
非常感谢。