Android SSL 尝试与 GAE/Java 连接失败
我正在尝试使用 Android 附带的 HTTPClient 4 实现将 Android 应用程序与托管在 Google App Engine for Java (https://applicationname.appspot.com) 中的安全 HTTPS 远程服务连接起来。该证书已签名且有效,格式为 *.appspot.com。
我在真实设备 (HTC Hero) 中使用 Android 2.1,并且收到以下错误:SSL23_GET_SERVER_HELLO:未知协议
。
这是我的代码的一部分:
HttpParams params = new BasicHttpParams();
...
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(
new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
schemeRegistry.register(
new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
..
ClientConnectionManager cm =
new ThreadSafeClientConnManager(params, schemeRegistry);
DefaultHttpClient result = new DefaultHttpClient(cm, params);
对可能发生的情况以及任何解决方案或解决方法有任何想法吗?
这是完整的堆栈跟踪:
09-25 18:19:05.452: ERROR/OpenSSLSocketImpl(1195): Unknown error 1 during connect
09-25 18:19:05.460: ERROR/ServerProxy(1195): HTTPHelp : IOException : java.io.IOException: SSL handshake failure: Failure in SSL library, usually a protocol error
09-25 18:19:05.460: ERROR/ServerProxy(1195): error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol (external/openssl/ssl/s23_clnt.c:585 0xaf586674:0x00000000)
09-25 18:19:05.460: ERROR/ServerProxy(1195): java.io.IOException: SSL handshake failure: Failure in SSL library, usually a protocol error
09-25 18:19:05.460: ERROR/ServerProxy(1195): error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol (external/openssl/ssl/s23_clnt.c:585 0xaf586674:0x00000000)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.nativeconnect(Native Method)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:305)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl$SSLInputStream.<init>(OpenSSLSocketImpl.java:502)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.getInputStream(OpenSSLSocketImpl.java:443)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.http.impl.io.SocketInputBuffer.<init>(SocketInputBuffer.java:93)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.http.impl.SocketHttpClientConnection.createSessionInputBuffer(SocketHttpClientConnection.java:83)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.http.impl.conn.DefaultClientConnection.createSessionInputBuffer(DefaultClientConnection.java:170)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.http.impl.SocketHttpClientConnection.bind(SocketHttpClientConnection.java:106)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.http.impl.conn.DefaultClientConnection.openCompleted(DefaultClientConnection.java:129)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:136)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:348)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
非常感谢。
I am trying to connect an Android application with a secured HTTPS remote service that is hosted in Google App Engine for Java (https://applicationname.appspot.com), using the HTTPClient 4 implementation that comes with Android. The certificate is signed and valid form *.appspot.com.
I am using Android 2.1 in a real device (HTC Hero), and I get the following error: SSL23_GET_SERVER_HELLO:unknown protocol
.
This is part of my code:
HttpParams params = new BasicHttpParams();
...
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(
new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
schemeRegistry.register(
new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
..
ClientConnectionManager cm =
new ThreadSafeClientConnManager(params, schemeRegistry);
DefaultHttpClient result = new DefaultHttpClient(cm, params);
Any idea about what could be happening and any solution or workaround?
This is the complete stack trace:
09-25 18:19:05.452: ERROR/OpenSSLSocketImpl(1195): Unknown error 1 during connect
09-25 18:19:05.460: ERROR/ServerProxy(1195): HTTPHelp : IOException : java.io.IOException: SSL handshake failure: Failure in SSL library, usually a protocol error
09-25 18:19:05.460: ERROR/ServerProxy(1195): error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol (external/openssl/ssl/s23_clnt.c:585 0xaf586674:0x00000000)
09-25 18:19:05.460: ERROR/ServerProxy(1195): java.io.IOException: SSL handshake failure: Failure in SSL library, usually a protocol error
09-25 18:19:05.460: ERROR/ServerProxy(1195): error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol (external/openssl/ssl/s23_clnt.c:585 0xaf586674:0x00000000)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.nativeconnect(Native Method)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:305)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl$SSLInputStream.<init>(OpenSSLSocketImpl.java:502)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.getInputStream(OpenSSLSocketImpl.java:443)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.http.impl.io.SocketInputBuffer.<init>(SocketInputBuffer.java:93)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.http.impl.SocketHttpClientConnection.createSessionInputBuffer(SocketHttpClientConnection.java:83)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.http.impl.conn.DefaultClientConnection.createSessionInputBuffer(DefaultClientConnection.java:170)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.http.impl.SocketHttpClientConnection.bind(SocketHttpClientConnection.java:106)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.http.impl.conn.DefaultClientConnection.openCompleted(DefaultClientConnection.java:129)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:136)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:348)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
09-25 18:19:05.460: ERROR/ServerProxy(1195): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
Thank you very much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不使用 Java,但对于 GAE——您是否在 app.yaml 中使用“安全”参数? http://code.google.com/appengine/kb/general.html#https
I don't use Java, but as for GAE -- are you using a "secure" parameter in your app.yaml? http://code.google.com/appengine/kb/general.html#https