プロジェクト | SSLConnection |
ソースファイル | MainActivity.java |
try { //Private証明書をassetsから読み込み、検証 KeyStore ks = KeyStoreUtil.getEmptyKeyStore(); KeyStoreUtil.loadX509Certificate(ks, mContext.getResources().getAssets().open("server.crt")); // ▼▼▼脆弱性のあるソースコード▼▼▼ // 1.独自でTrustManagerを実装したクラス(PrivateSSLSocketFactory)を実装 // 2.HostnameVerifierにSSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIERをセット SSLSocketFactory sslSocketFactory = new PrivateSSLSocketFactory(ks); sslSocketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); Scheme sch = new Scheme("https", sslSocketFactory, 443); // ▲▲▲脆弱性のあるソースコード▲▲▲ client.getConnectionManager().getSchemeRegistry().register(sch); HttpGet request = new HttpGet(params[0]); HttpResponse response = client.execute(request); webView.loadData(EntityUtils.toString(response.getEntity()), "text/html", "UTF-8"); // ▼▼▼脆弱性のあるソースコード▼▼▼ } catch (Exception e) { } // ▲▲▲脆弱性のあるソースコード▲▲▲ return null; } } |