【发布时间】:2016-03-01 23:20:12
【问题描述】:
我正在与一个 Android 应用程序的团队合作,并被分配了设置用户登录和注册页面的任务。在设置我的服务器类以使用 HttpsURLConnection 类发布后,我收到了 SSLHandshakeException 错误。
HttpsURL连接代码
HttpsURLConnection connection = (HttpsURLConnection) new URL(spec.toString()).openConnection();
经过一些研究,我意识到这是因为 Android 不信任我们的服务器,因为它是自签名的。我正在尝试从 Android 开发网站关注此 documentation,但不明白如何获取 crt 文件。我使用的是 AWS 服务器,但我不是设置自签名证书的人,但我确实拥有对服务器的完全访问权限。
来自 Android Docs(如何获取 load-der.crt 文件?)
// Load CAs from an InputStream
// (could be from a resource or ByteArrayInputStream or ...)
CertificateFactory cf = CertificateFactory.getInstance("X.509");
// From https://www.washington.edu/itconnect/security/ca/load-der.crt
InputStream caInput = new BufferedInputStream(new FileInputStream("load-der.crt"));
Certificate ca;
【问题讨论】:
-
无法再访问washington.edu 的网址。
-
您是自己创建的证书还是由网络管理员或后端提供的。
标签: android ssl amazon-web-services ssl-certificate self-signed