尝试从URL读取XML时遇到SSLHandshakeException。 错误发生在这一行: Document doc = db.parse(new InputSource(url.openStream()));
protected LinearLayout doInBackground(String... string) {
LinearLayout layout = new LinearLayout(DevicesActivity.this);
layout.setOrientation(1);
/** Create a new textview array to display the results */
TextView device[];
try {
URL url = new URL();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(new InputSource(url.openStream()));
doc.getDocumentElement().normalize();
日志:
05-30 15:18:21.742: I/Choreographer(12300): Skipped 59 frames! The application may be doing too much work on its main thread.
05-30 15:18:22.305: I/ActivityManager(290): Displayed com.example.wip/.DevicesActivity: +2s340ms
05-30 15:18:23.992: I/System.out(12300): XML Pasing Excpetion = javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
当我尝试查看网址的页面信息时,我也从Chrome收到了此消息
the identity of this website has not been verified.• server's certificate is not trusted
这是网站服务器的问题吗?我可以把它固定在我身边吗?
答案 0 :(得分:1)
问题出在服务器端。它使用的是错误的证书。 (根据firefox的说法,服务器不包括票证发行者链。这甚至不是自签名证书。它只是配置错误。)
我可以把它固定在我身边吗?
您需要将服务器的证书作为可信证书添加到手机的密钥库中。我不确定这是个好主意。