0

尝试从 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.

当我尝试查看 URL 的页面信息时,我也从 Chrome 收到了这条消息

the identity of this website has not been verified.• server's certificate is not trusted

这是网站服务器的问题吗?我可以在我这边修吗?

4

1 回答 1

1

问题出在服务器端。它使用了错误的证书。(根据火狐的说法,服务器不包括票证发行者链。这甚至不是自签名证书。它只是配置错误。)

我可以在我这边修吗?

您需要将服务器的证书作为可信证书添加到手机的密钥库中。我不确定这是个好主意。

于 2013-05-30T15:44:21.720 回答