简体   繁体   English

Android SSL https帖子

[英]Android SSL https post

I've seen a lot of similar question here but couldn't find the solution. 我在这里看到了很多类似的问题,但找不到解决方案。 I have a webservice PHP file hosted at x10 premium. 我有一个x10 premium托管的webservice PHP文件。 I bought an SSL certificate from them and can access my webpage via https on a browser and on the iPhone app. 我从他们那里购买了SSL证书,可以通过浏览器和iPhone应用程序上的https访问我的网页。 I'm having trouble doing the same on the Android app. 我在Android应用上遇到同样的问题。

I tried many solutions, but keep getting SSL errors. 我尝试了很多解决方案,但不断收到SSL错误。 I tried this tutorial http://www.makeurownrules.com/secure-rest-web-service-mobile-application-android.html but I'm getting 我试过这个教程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)

I tried other suggestions here on SO, for accepting all certificates, since I'm making a call to my own webservice and trust all certificates. 我在SO上尝试了其他建议,接受所有证书,因为我打电话给我自己的网络服务并信任所有证书。

Another thing, I can access in a browser and the iPhone app to my webservice via HTTP connection. 另一件事,我可以通过HTTP连接访问浏览器和iPhone应用程序到我的webservice。 But when I try to make it in Android, I'm receiving back HTML response which contains 但是当我尝试在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>

Any ideas? 有任何想法吗?

Thanks! 谢谢!

There is a known problem with certificates and Android. 证书和Android存在已知问题。 Read this thread: Not trusted certificate using ksoap2-android 阅读此主题: 使用kso​​ap2-android不可信任的证书

There is a solution to use HTTPs on Android. 有一种在Android上使用HTTP的解决方案。

[]s Neto [] s Neto

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM