我正在尝试使用 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:unknown protocol
.
这是我的代码的一部分:
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)
非常感谢。