我正在猜测,但是如果你想进行实际的握手,则必须让android知道你的证书。如果你只想接受任何内容,请使用以下伪代码通过Apache HTTP Client获得所需的内容:
SchemeRegistry schemeRegistry = new SchemeRegistry ();schemeRegistry.register (new Scheme ("http", PlainSocketFactory.getSocketFactory (), 80));schemeRegistry.register (new Scheme ("https", new CustomSSLSocketFactory (), 443));ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager ( params, schemeRegistry);return new DefaultHttpClient (cm, params);CustomSSLSocketFactory:
public class CustomSSLSocketFactory extends org.apache.http.conn.ssl.SSLSocketFactory{private SSLSocketFactory FACTORY = HttpsURLConnection.getDefaultSSLSocketFactory ();public CustomSSLSocketFactory () { super(null); try { SSLContext context = SSLContext.getInstance ("TLS"); TrustManager[] tm = new TrustManager[] { new FullX509TrustManager () }; context.init (null, tm, new SecureRandom ()); FACTORY = context.getSocketFactory (); } catch (Exception e) { e.printStackTrace(); } }public Socket createSocket() throws IOException{ return FACTORY.createSocket();} // TODO: add other methods like createSocket() and getDefaultCipherSuites(). // Hint: they all just make a call to member FACTORY }FullX509TrustManager是一个实现javax.net.ssl.X509TrustManager的类,但实际上没有任何方法可以执行任何工作,请在此处获取示例。
祝好运!



