0

我想解析受 SSL (https) 保护的 JSON,在 Android 2.x 上我获得:“No Peer Certificate Exception”,而且我(几乎)对证书一无所知,有人可以解释如何步骤逐步将 SSL 证书集成到我的应用程序并使用它(我知道我必须这样做)。那是我当前的代码:

HttpGet httppost =  new HttpGet(url);
httppost.setHeader("Content-type", "application/json");
response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
inputStream = entity.getContent();
4

1 回答 1

1

异常意味着设备不信任您服务器的证书。如果使用的服务器证书是付费的(由信任中心购买),这意味着该设备上不存在信任中心证书。

您可以将信任中心证书(或自签名证书)添加到您的应用程序中,方法是将其放入 BouncyCastle Keystore (BKS)

请注意,最新版本的BouncyCastle默认会生成 Android 无法读取的较新版本的 BKS 文件。您需要 BouncyCastle 1.46。

另见: http ://randomizedsort.blogspot.de/2010/09/step-to-step-guide-to-programming.html

于 2013-05-16T14:44:29.793 回答