MIDLET 中的 HTTPS
我开发了一个应用程序,它可以点击受保护的网址。当我使用“https”点击此网址时,我在模拟器中得到“证书已过期”,在真实设备中得到“证书验证失败”。下面是代码片段:
String loginUrl= "https://myhost.com/somefile";
HttpConnection httpConn = null;
DataOutputStream dataOS = null;
System.out.println("strModuleName.trim()::::"
+ strModuleName.trim());
httpConn = (HttpConnection) Connector.open(loginUrl);//, Connector.READ_WRITE);
httpConn.setRequestProperty("User-Agent",
"Profile/MIDP-2.0, Configuration/CLDC-1.0");
httpConn.setRequestProperty("Connection", "Keep-Alive");
httpConn.setRequestProperty("Content-Language", "en-US");
httpConn.setRequestMethod(HttpConnection.POST);
dataOS = (DataOutputStream) httpConn.openDataOutputStream();
I have developed an app which hits the url which is secured.when I hit this url using "https" I get "Certificate is expired" in simulator or "Certificate failed verification" in real device. below is the snippet of the code:
String loginUrl= "https://myhost.com/somefile";
HttpConnection httpConn = null;
DataOutputStream dataOS = null;
System.out.println("strModuleName.trim()::::"
+ strModuleName.trim());
httpConn = (HttpConnection) Connector.open(loginUrl);//, Connector.READ_WRITE);
httpConn.setRequestProperty("User-Agent",
"Profile/MIDP-2.0, Configuration/CLDC-1.0");
httpConn.setRequestProperty("Connection", "Keep-Alive");
httpConn.setRequestProperty("Content-Language", "en-US");
httpConn.setRequestMethod(HttpConnection.POST);
dataOS = (DataOutputStream) httpConn.openDataOutputStream();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用 HTTPS,设备需要验证您的服务器 (myhost.com) 已安装的证书链。如果证书已过期,那么您需要将此情况告知网站管理员,以便他可以修复它。
如果证书链正确,则设备必须根据设备本身安装的证书对其进行验证。移动设备通常拥有来自主要证书颁发机构(Verisign 等)的证书。但如果您的服务器证书未安装在设备中,则需要先安装它才能建立 HTTP 连接。
If you're using HTTPS, the device need to validate the Certificate Chain that your server (myhost.com) has installed. If the certificate is expired, then you need to inform this to the webmaster so he can fix it.
If the certificate chain is correct, then the device has to validate it against the certificates that the device itself has installed. It's usual that mobile devices have certificates from the main certificates authorities (Verisign and others). But if your server's certificate is not installed in the device, you need to install it first to make the HTTP connection.