Android SSL https帖子

时间:2012-10-11 22:07:43

标签: java android http ssl https

我在这里看到了很多类似的问题,但找不到解决方案。 我有一个x10 premium托管的webservice PHP文件。我从他们那里购买了SSL证书,可以通过浏览器和iPhone应用程序上的https访问我的网页。我在Android应用程序上做同样的事情时遇到了麻烦。

我尝试了很多解决方案,但不断收到SSL错误。我试过这个教程http://www.makeurownrules.com/secure-rest-web-service-mobile-application-android.html 但我得到了

10-04 07:21:57.081: W/System.err(6804): javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x2a1a11a8: Failure in SSL library, usually a protocol error
10-04 07:21:57.081: W/System.err(6804): error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol (external/openssl/ssl/s23_clnt.c:766 0x471f5756:0x00000000)
10-04 07:21:57.091: W/System.err(6804):     at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:436)
10-04 07:21:57.123: W/System.err(6804):     at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl$SSLInputStream.<init (OpenSSLSocketImpl.java:647)
10-04 07:21:57.123: W/System.err(6804):     at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.getInputStream(OpenSSLSocketImpl.java:618)
10-04 07:21:57.123: W/System.err(6804):     at org.apache.http.impl.io.SocketInputBuffer.<init>(SocketInputBuffer.java:70)
10-04 07:21:57.131: W/System.err(6804):     at org.apache.http.impl.SocketHttpClientConnection.createSessionInputBuffer(SocketHttpClientConnection.java:83)
10-04 07:21:57.131: W/System.err(6804):     at org.apache.http.impl.conn.DefaultClientConnection.createSessionInputBuffer(DefaultClientConnection.java:170)
10-04 07:21:57.131: W/System.err(6804):     at org.apache.http.impl.SocketHttpClientConnection.bind(SocketHttpClientConnection.java:106)
10-04 07:21:57.131: W/System.err(6804):     at org.apache.http.impl.conn.DefaultClientConnection.openCompleted(DefaultClientConnection.java:129)
10-04 07:21:57.131: W/System.err(6804):     at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:172)
10-04 07:21:57.141: W/System.err(6804):     at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
10-04 07:21:57.141: W/System.err(6804):     at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
10-04 07:21:57.141: W/System.err(6804):     at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
10-04 07:21:57.141: W/System.err(6804):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
10-04 07:21:57.151: W/System.err(6804):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
10-04 07:21:57.151: W/System.err(6804):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
10-04 07:21:57.201: W/System.err(6804):     at com.lablabla.parkme.ParkMeActivity.performUpdate(ParkMeActivity.java:233)
10-04 07:21:57.211: W/System.err(6804):     at com.lablabla.parkme.ParkMeActivity.access$8(ParkMeActivity.java:220)
10-04 07:21:57.211: W/System.err(6804):     at com.lablabla.parkme.ParkMeActivity$3.onClick(ParkMeActivity.java:215)
10-04 07:21:57.211: W/System.err(6804):     at android.view.View.performClick(View.java:4084)
10-04 07:21:57.221: W/System.err(6804):     at android.view.View$PerformClick.run(View.java:16966)
10-04 07:21:57.221: W/System.err(6804):     at android.os.Handler.handleCallback(Handler.java:615)
10-04 07:21:57.221: W/System.err(6804):     at android.os.Handler.dispatchMessage(Handler.java:92)
10-04 07:21:57.241: W/System.err(6804):     at android.os.Looper.loop(Looper.java:137)
10-04 07:21:57.241: W/System.err(6804):     at android.app.ActivityThread.main(ActivityThread.java:4745)
10-04 07:21:57.251: W/System.err(6804):     at java.lang.reflect.Method.invokeNative(Native Method)
10-04 07:21:57.251: W/System.err(6804):     at java.lang.reflect.Method.invoke(Method.java:511)
10-04 07:21:57.271: W/System.err(6804):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
10-04 07:21:57.271: W/System.err(6804):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
10-04 07:21:57.281: W/System.err(6804):     at dalvik.system.NativeStart.main(Native Method)
10-04 07:21:57.291: W/System.err(6804): Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x2a1a11a8: Failure in SSL library, usually a protocol error
10-04 07:21:57.291: W/System.err(6804): error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol (external/openssl/ssl/s23_clnt.c:766 0x471f5756:0x00000000)
10-04 07:21:57.311: W/System.err(6804):     at org.apache.harmony.xnet.provider.jsse.NativeCrypto.SSL_do_handshake(Native Method)
10-04 07:21:57.311: W/System.err(6804):     at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:395)

我在SO上尝试了其他建议,接受所有证书,因为我打电话给我自己的网络服务并信任所有证书。

另一件事,我可以通过HTTP连接在浏览器和iPhone应用程序中访问我的web服务。但是当我尝试在Android中制作它时,我收到了包含

的HTML响应
10-04 07:29:47.662: D/RESULT(6900):  instead of REQUEST_URI, we could show absolute URL via:
10-04 07:29:47.662: D/RESULT(6900):  http://HTTP_HOST/REQUEST_URI
10-04 07:29:47.662: D/RESULT(6900):     but what if its https:// or other protocol?
10-04 07:29:47.662: D/RESULT(6900):     
10-04 07:29:47.662: D/RESULT(6900):     SERVER_PORT_SECURE doesn't seem to be used
10-04 07:29:47.662: D/RESULT(6900):     SERVER_PORT logic would break if they use alternate ports
10-04 07:29:47.662: D/RESULT(6900): -->
10-04 07:29:47.662: D/RESULT(6900): <h1>404 Not Found</h1>

有什么想法吗?

谢谢!

1 个答案:

答案 0 :(得分:4)

证书和Android存在已知问题。 阅读此主题:Not trusted certificate using ksoap2-android

有一种在Android上使用HTTP的解决方案。

[]中 内托