認証局に頼るのではなく、Android アプリで自己署名証明書を使用したいと考えています。
そうする理由といくつかの例を含むこのリンク(thoughcrime.org)を見つけましたが、ループシナリオに適応させることができませんでした(サーバーから応答がありません。以下を参照)。
次に、同じ問題に対処する他のリンク ( sproutsocialとAntoine のブログ) にたどり着きました。これには、loopj と volley のスニペットが含まれます。最後に、以下のコードを使用しました。
private static SSLSocketFactory getSSLSocketFactory(){
try {
// Get an instance of the Bouncy Castle KeyStore format
KeyStore trusted = KeyStore.getInstance("BKS");
// Get the raw resource, which contains the keystore with
// your trusted certificates (root and any intermediate certs)
InputStream in = context.getResources().openRawResource(R.raw.mykeystore);
try {
// Initialize the keystore with the provided trusted certificates
// Also provide the password of the keystore
trusted.load(in, "mysecret".toCharArray());
} finally {
in.close();
}
// Pass the keystore to the SSLSocketFactory. The factory is responsible
// for the verification of the server certificate.
SSLSocketFactory sf = new SSLSocketFactory(trusted);
// Hostname verification from certificate
// http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html#d4e506
sf.setHostnameVerifier(SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
return sf;
} catch (Exception e) {
throw new AssertionError(e);
}
}
で接続呼び出しを行うAsyncHttpClient
たびに、クライアントの SSLSocketFactory を次のように設定します。
private static AsyncHttpClient client = new AsyncHttpClient();
client.setSSLSocketFactory(getSSLSocketFactory());
キーストアを作成するとき、すべての端末出力はAntoine のブログで説明されているとおりです
それにもかかわらず、 myJsonHttpResponseHandler
は何も受信せず、そのonSuccess
/onFailure
メソッドは呼び出されません。
これについて何か助けていただければ幸いです。ありがとう!
編集 -この質問は私のものと同じ問題に関するものですが、回答がありません