httpclient访问https服务,可以信任证书
private HttpClient initHttpClient() {if(httpclient == null){try {X509TrustManager tm = new X509TrustManager() {public void checkClientTrusted(X509Certificate[] arg0,String arg1) throws CertificateException {}public void checkServerTrusted(X509Certificate[] arg0,String arg1) throws CertificateException {}public X509Certificate[] getAcceptedIssuers() {return null;}};SSLContext sslcontext = SSLContext.getInstance("TLS");sslcontext.init(null, new TrustManager[] { tm }, null);SSLSocketFactory ssf = new SSLSocketFactory(sslcontext);ClientConnectionManager ccm = new DefaultHttpClient().getConnectionManager();SchemeRegistry sr = ccm.getSchemeRegistry();sr.register(new Scheme("https", 8443, ssf));HttpParams params = new BasicHttpParams();params.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 1000);params.setParameter(CoreConnectionPNames.SO_TIMEOUT, 5000);httpclient = new DefaultHttpClient(ccm,params);} catch (Exception ex) {ex.printStackTrace();}}return httpclient;} ?