https - Tag -http://houugen.fun/tags/https.htmlhttps - Tag -Hugo -- gohugo.ioenSat, 24 Mar 2018 15:14:58 +0000android网络请求&证书认证http://houugen.fun/posts/android%E7%BD%91%E7%BB%9C%E8%AF%B7%E6%B1%82-%E8%AF%81%E4%B9%A6%E8%AE%A4%E8%AF%81.htmlSat, 24 Mar 2018 15:14:58 +0000Authorhttp://houugen.fun/posts/android%E7%BD%91%E7%BB%9C%E8%AF%B7%E6%B1%82-%E8%AF%81%E4%B9%A6%E8%AE%A4%E8%AF%81.html0x00 目的 通过使用HttpClinet、HttpURLConnect、Volley、Okhttp、Retrofit及Webview,快速识别android网络请求框架为了能定位关键代码,完全理解不正确及正确的证书、域名及sslpinning校验过程。 0x01 HttpClient & HttpURLConnection 发送请求 android 6.0 删除HttpClient类库,仍需使用的方法: eclipse:libs中加入org.apache.http.legacy.jar AS:在build.gradle中加入 android { useLibrary 'org.apache.http.legacy' } 使用HttpClient发送Http GET请求 HttpClient mHttpClient = new DefaultHttpClient(); HttpGet mHttpGet = new HttpGet(url); HttpResponse mHttpResponse = mHttpClient.execute(mHttpGet); HttpEntity mHttpEntity = mHttpResponse.getEntity(); DefaultHttpClient with default constructor is not compatible with TLS 1.2 建议使用SystemDefaultHttpClient代替: HttpClient client = new SystemDefaultHttpClient(); or HttpClient client = HttpClientBuilder.create().useSystemProperties().build(); 使用HttpURLConnection发送Http GET请求 URL url = new URL(url); HttpURLConnection urlConnection = (HttpURLConnection)url.