gpt4 book ai didi

尝试连接 GAE/Java 的 Android SSL 失败

转载 作者:行者123 更新时间:2023-11-29 14:10:17 25 4
gpt4 key购买 nike

我正在尝试使用 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)

非常感谢。

最佳答案

我不使用 Java,但至于 GAE——您是否在 app.yaml 中使用了“安全”参数? http://code.google.com/appengine/kb/general.html#https

关于尝试连接 GAE/Java 的 Android SSL 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3794552/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com