Недавно я сделал самостоятельно опалены сертификат на веб-сервере Apache с помощью этого учебника:андроида самостоятельно подписанный сертификат не будет работать
http://theheat.dk/blog/?p=1023&cpage=1
веб-службы требуют сертификат, чтобы открыть. в браузере все идет хорошо. Я импортировал сертификаты, и сайт откроется.
Я сделал файл BKS от rootCA.crt, client.crt, winter fall.crt, но никто не работает.
В Android я
SSL3_GET_CLIENT_CERTIFICATE: равный не возвращал сертификат Нет ЦС известный сервер для проверки?
сообщение об ошибке в журнале apache.
Кажется, моя проблема заключается в комбинации сертификатов для отправки на сервер! в браузере я использую клиент и rootCA, как я могу объединить их для отправки на веб-сервер?
Мой код:
try {
DefaultHttpClient httpclient = new MyHttpClient(getApplicationContext());
HttpGet get = new HttpGet("https://xxx.xxx.xxx.xxx/index.php");
try {
HttpResponse response = httpclient.execute(get);
} catch (ClientProtocolException e) {
System.out.println(e.getMessage());
} catch (IOException e) {
System.out.println(e.getMessage());
}
return "OK";
} catch (Exception err) {
return "Err";
}
И
public class MyHttpClient extends DefaultHttpClient {
final Context context;
public MyHttpClient(Context context) {
this.context = context;
}
@Override
protected ClientConnectionManager createClientConnectionManager() {
SchemeRegistry registry = new SchemeRegistry();
// Register for port 443 our SSLSocketFactory with our keystore
// to the ConnectionManager
registry.register(new Scheme("https", newSslSocketFactory(), 443));
return new SingleClientConnManager(getParams(), registry);
}
private SSLSocketFactory newSslSocketFactory() {
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.comb);
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.ALLOW_ALL_HOSTNAME_VERIFIER);
HttpsURLConnection.setDefaultHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
return sf;
} catch (Exception e) {
throw new AssertionError(e);
}
}
Ваш помогает очень ценна!
Отправьте свой код. –
мой код прилагается – Mehdi
В какой версии Android вы столкнулись с этой проблемой? –