1
我有使用在Android 2.2 SSL一些困难的Android 2.2 Froyo 我的自定义HTTP客户端的SSL工作finly较早和较旧版本的Android, ,但对2.2 HTTPS请求不运行所有ATT 。 这里我的代码:解决粗野,用DefaultHttpClient
public class SSLHttpClient extends DefaultHttpClient {
final Context context;
public SSLHttpClient(Context context,HttpParams params) {
super(params);
this.context = context;
}
@Override
protected ClientConnectionManager createClientConnectionManager() {
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("http", PlainSocketFactory
.getSocketFactory(), 80));
registry.register(new Scheme("https", newSslSocketFactory(), 443));
return new SingleClientConnManager(getParams(), registry);
}
private SSLSocketFactory newSslSocketFactory() {
try {
SSLSocketFactory sf = new SSLSocketFactory(keyStore,"",trustStore);
//---------some code--------------------------------------
return sf;
} catch (Exception e) {
throw new AssertionError(e);
}
}
}
我发现了一些类似的文章,但他们并没有解决我的问题。 也许有人遇到这样的问题。 在此先感谢......
你说的不工作的意思。你得到什么错误。 – 2011-05-30 15:32:09
我有这样的问题: http://stackoverflow.com/questions/2899079/custom-ssl-handling-stopped-working-on-android-2-2-froyo 但是,从这里的解决方案并没有帮助我。 在此先感谢。 – drifter 2011-06-01 16:55:41