HTTPS GET(SSL)与Android和自签署的服务器证书 [英] HTTPS GET (SSL) with Android and self-signed server certificate

查看:242
本文介绍了HTTPS GET(SSL)与Android和自签署的服务器证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经研究过各种职务有关如何检索通过 HTTPS 的东西在Android上,从使用自签名证书的服务器。然而,他们都不工作 - 他们都无法删除

I have looked into various posts about how to retrieve something via HTTPS on Android, from a server that uses a self-signed certificate. However, none of them seem to work - they all fail to remove the

javax.net.ssl​​.SSLException:不被信任的服务器证书信息。

javax.net.ssl.SSLException: Not trusted server certificate message.

这是不是一种选择修改服务器有一个信任的证书,它也不是一个选项,以使服务器证书相匹配的服务器的IP地址。

It is not an option to modify the server to have a trusted certificate, and it is also not an option to make the server certificate match the server's IP address.

请注意,服务器将不会有一个DNS名称,它只会有一个IP地址。 GET请求看起来是这样的:

Note, that the server will not have a DNS name, it will only have an IP-address. The GET request looks something like this:

 https://username:password@anyIPAddress/blabla/index.php?param=1&param2=3

我充分认识到,这种解决方案很容易出现人在这方面的中间人攻击等。

I am fully aware that this solution is prone to man-in-the-middle attacks etc.

因此​​,该解决方案必须忽略缺乏证书中的信任,而忽视了主机名不匹配

So, the solution must ignore the lack of trust in the certificate, and ignore the hostname mismatch.

有谁知道code,即是这种情况,使用Java为Android?

Does anybody know the code, that does this, using Java for Android?

有很多试图解释这对 stackoverflow.com 和大量的code片段,但他们不似乎工作,没有人已经提供了code一个块,解决了这一点,据我所看到的。这将是有趣的知道,如果有人真的解决了这一点,如果不受信任的Andr​​oid只是块证书。

There are plenty of attempts to explain this on stackoverflow.com, and plenty of code snippets, but they don't seem to work, and nobody has provided one block of code that solves this, as far as I can see. It would be interesting to know if somebody really solved this, or if Android simply blocks certificates that are not trusted.

推荐答案

我在使用自签名或信任所有证书的应用程序。该人士是在这里:<一href="http://$c$c.google.com/p/meneameandroid/source/browse/#svn/trunk/src/com/dcg/auth">http://$c$c.google.com/p/meneameandroid/source/browse/#svn/trunk/src/com/dcg/auth并免费使用:P

I made an app that uses self-signed or trust all certs. The source is here: http://code.google.com/p/meneameandroid/source/browse/#svn/trunk/src/com/dcg/auth and free to use :P

只需使用HttpManager并利用信托都是一个创建SSL工厂:<一href="http://$c$c.google.com/p/meneameandroid/source/browse/trunk/src/com/dcg/util/HttpManager.java">http://$c$c.google.com/p/meneameandroid/source/browse/trunk/src/com/dcg/util/HttpManager.java

Just use the HttpManager and create the SSL factory using the trust all one: http://code.google.com/p/meneameandroid/source/browse/trunk/src/com/dcg/util/HttpManager.java

编辑:链接更新

这篇关于HTTPS GET(SSL)与Android和自签署的服务器证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆