Bouncy Castle Keystore (BKS): java.io.IOException: Versión incorrecta del almacén de claves

Tengo que conectarme a un servicio basado en REST.

( Https://someurl.com/api/lookup/jobfunction/lang/EN )

En el IE o el cromo browser cuando intento tener acceso a esta URL, consigo un certificado que tengo que confiar y aceptar para continuar después de que tengo que incorporar el username y la contraseña y entonces consigo la respuesta de JSON.

Lo mismo tengo que hacer programáticamente para una aplicación para Android.

  1. Probado con EasySSLSocketFactory personalizado y EasyX509TrustManager, Didnt trabajo. Conseguí el error siguiente: java.security.cert.CertPathValidatorException: El ancla de la confianza para la trayectoria de la certificación no encontró.

  2. Utilizó el BKS keystore, tenga en cuenta que mykeystore.bks es un archivo vacío antes de ejecutar los comandos siguientes

    keytool -importcert -v -trustcacerts -file "test.crt" -alias IntermediateCA -keystore "mykeystore.bks" -provider org.bouncycastle.jce.provider.BouncyCastleProvider -providerpath "bcprov-jdk15on-148.jar" -storetype BKS -storepass abcd1234 keytool -list -keystore "mykeystore.bks" -provider org.bouncycastle.jce.provider.BouncyCastleProvider -providerpath "bcprov-jdk15on-148.jar" -storetype BKS -storepass abcd1234 

MyHTTPClient.java se ve como a continuación:

 public class MyHttpClient extends DefaultHttpClient { final Context context; public MyHttpClient(Context context) { this.context = context; } @Override protected ClientConnectionManager createClientConnectionManager() { SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); // 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.mykeystore); try { // Initialize the keystore with the provided trusted certificates // Also provide the password of the keystore trusted.load(in, "abcd1234".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); } } 

Cuando llamo al webservice, estoy recibiendo el siguiente error: Causado por: java.lang.AssertionError: java.io.IOException: Versión incorrecta del almacén de claves

Por favor, dime lo que tengo que hacer para conectarse a HTTPS basado en reposo webservice que tiene nombre de usuario y passwd credenciales. ……

FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.