问题描述:
android 需要支持https界面或者对应的接口调用,不希望接口参数明文传输。
实现方案:
android HttpClient 提供添加ssl支持,其需要添加以下代码:
SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443)); ClientConnectionManager conMgr = new ThreadSafeClientConnManager( httpParams, schemeRegistry); httpClient = new DefaultHttpClient(conMgr,httpParams); |
当然server端也必须安装相应的证书,否则会报证书错误不能加载。