title: Android 4.1.2: KeyStore BKS implementation not found
body: <p>i have a problem with the BouncyCastle-Format on Android 4.1.2.</p>
  
  <p>In my app i use SSL-Pinning to protect my customers from MITM-Attack. The public ssl certificate is stored in the raw resource directory. All works fine, but on Android 4.1.2 it will crash by initialize the KeyStore.</p>
  
  <p>Currently affected devices are: Samsung GT18190/GT18190N ; Sony ST26I ; LG P880 - all with Android 4.1.2</p>
  
  <p>Here is my Code for creating a SSLSocketFactory:</p>
  
  <pre><code>import android.content.Context;
  
  import java.io.InputStream;
  import java.security.KeyStore;
  
  import javax.net.ssl.SSLContext;
  import javax.net.ssl.TrustManagerFactory;
  
  
  public class SSLSocket {
  
  public static javax.net.ssl.SSLSocketFactory newSslSocketFactory(Context ctx) {
      char[] KEYSTORE_PASSWORD = "MYKEYSTOREPASSWORD".toCharArray();
      try {
          KeyStore trusted = KeyStore.getInstance("BKS");
          InputStream in = ctx.getResources().openRawResource(R.raw.ssl);
          try {
              trusted.load(in, KEYSTORE_PASSWORD);
          } finally {
              in.close();
          }
  
          String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
          TrustManagerFactory tmf = TrustManagerFactory.getInstance(tmfAlgorithm);
          tmf.init(trusted);
  
          SSLContext context = SSLContext.getInstance("TLS");
          context.init(null, tmf.getTrustManagers(), null);
  
          return context.getSocketFactory();
      } catch (Exception e) {
          throw new AssertionError(e);
      }
  }
  }
  </code></pre>
  
  <p>The following exception is thrown:</p>
  
  <p>java.lang.AssertionError: java.security.KeyStoreException: java.security.NoSuchAlgorithmException: KeyStore BKS implementation not found</p>
  
  <p>Have anyone an idea for solving the issue for Android 4.1.2?</p>