title: How to create and populate a Keystore object from an X509Certificate string
body: <p>I have a string that I'm passing around which represents an X509Certificate generated by:</p>
  
  <pre><code>String strMessage = 
        Base64.encodeToString(chain[0].getEncoded(), android.util.Base64.NO_WRAP);
  </code></pre>
  
  <p>This is so the user can view a certificate and possibly accept it.  If they do decide to accept it I need to create a Keystore object to which to add to my custom SSL factory (as here:)</p>
  
  <pre><code>private SSLSocketFactory newSslSocketFactory(boolean trustCert, String cert) {
      try {
          KeyStore trusted = KeyStore.getInstance("BKS");
          if(trustCert) {
              String cert_begin = "-----BEGIN CERTIFICATE-----\n";
              String end_cert = "-----END CERTIFICATE-----";
              String strCert = cert_begin + cert + end_cert;
  
              byte[] bytes = Base64.decode(cert.getBytes(), Base64.DEFAULT);                    
              InputStream bis = new ByteArrayInputStream(bytes);
              try {
                  trusted.load(bis, "password".toCharArray());
              }
              catch(Exception e) {
                  int j;
                  j = 10;
              }
              finally {
                  bis.close();
              }
          }
          AdditionalKeyStoresSSLSocketFactory af = new AdditionalKeyStoresSSLSocketFactory(trusted, null, mTrustCert, mCert);
          af.setHostnameVerifier(SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
          return af;
      } 
      catch (Exception e)  {
          throw new AssertionError(e);
      }
  }
  </code></pre>
  
  <p>But this does not seem to be working.  When I iterate through my list it is not finding it
  Any ideas?
  /Loren</p>