[英]Android Studio HTTPS and SSL Certificate
currently, i'm in the midst of developing mobile apps for Android using Android Studio. 目前,我正在使用Android Studio开发适用于Android的移动应用程序。
so far, login/senddata/getdata/viewdata in my mobile apps work like a charm in my local PC and HTTP web . 到目前为止,我的移动应用程序中的login / senddata / getdata / viewdata在我的本地PC和HTTP网站中就像一个超级按钮一样工作。 i use HttpUrlConnection in my coding
我在编码中使用HttpUrlConnection
the problem is how to make my mobile apps run/send data/retrieve data/communicate with PHPMySQL in my HTTPS server. 问题是如何使我的移动应用程序在HTTPS服务器中运行/发送数据/检索数据/与PHPMySQL通信。
its only working on HTTP web server. 它仅适用于HTTP Web服务器。 HTTPS does not work at all and my mobile apps is crashed and stop working.
HTTPS根本不起作用,我的移动应用程序已崩溃并停止工作。
i have test my mobile apps into both HTTP & HTTPS server (SSL & Self-signed certificate) 我已经在HTTP和HTTPS服务器(SSL和自签名证书)中测试了我的移动应用程序
is there any addition on the coding that i need to be aware of to make it accessible into HTTPS ? 为了使HTTPS可以访问它,我需要了解编码上的任何其他内容吗?
Thanks. 谢谢。
The official Android documentation for HTTPS has details about how HTTPS connections work in Android, including commonly seen errors. Android的HTTPS官方文档详细介绍了HTTPS连接在Android中的工作方式,包括常见错误。
If you have a trusted certificate that was issued by a CA or a reseller, your current code with HttpURLConnection should work fine. 如果您拥有由CA或经销商发行的受信任证书,则使用HttpURLConnection的当前代码应该可以正常工作。 From https://developer.android.com/reference/java/net/HttpURLConnection.html ,
从https://developer.android.com/reference/java/net/HttpURLConnection.html ,
Calling
openConnection()
on a URL with the "https" scheme will return anHttpsURLConnection
, which allows for overriding the defaultHostnameVerifier
andSSLSocketFactory
.使用“ https”方案在URL上调用
openConnection()
将返回HttpsURLConnection
,它允许覆盖默认的HostnameVerifier
和SSLSocketFactory
。 An application-suppliedSSLSocketFactory
created from anSSLContext
can provide a customX509TrustManager
for verifying certificate chains and a customX509KeyManager
for supplying client certificates.从
SSLContext
创建的应用程序提供的SSLSocketFactory
可以提供用于验证证书链的自定义X509TrustManager
和用于提供客户端证书的自定义X509KeyManager
。
If you're using self signed certificates (not recommended in Production), this article at CodeProject describes the process to handle this. 如果您使用的是自签名证书(在Production中不建议使用),则CodeProject上的本文介绍了处理此问题的过程。
有了自动证书,您将无法使用7天免费ssl试用https://www.globessl.com/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.