Récemment, je fait un certificat auto-roussi dans le serveur web Apache en utilisant ce tutoriel:certificat auto-signé android ne fonctionnera pas
http://theheat.dk/blog/?p=1023&cpage=1
service Web nécessitent un certificat d'ouvrir. dans le navigateur tout va bien. J'ai importé des certificats et le site s'ouvrira.
J'ai fait le fichier BKS à partir de rootCA.crt, client.crt, winter fell.crt, Mais personne ne travaille.
Dans Android Je reçois
SSL3_GET_CLIENT_CERTIFICATE: par les pairs n'a pas retourné un certificat Aucune autorité de certification connu au serveur pour la vérification?
message d'erreur dans le journal Apache.
Il semble que mon problème concerne la combinaison de certificats à envoyer au serveur! dans le navigateur j'utilise client et rootCA, comment puis-je les combiner pour envoyer au serveur web?
Mon code:
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";
}
Et
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);
}
}
Votre aide vraiment apprécié!
Postez votre code. –
mon code attaché – Mehdi
Quelle version d'Android rencontrez-vous sur ce problème? –