title: How to enable a self-signed certificate for SSL sockets on Android?
body: <p>I have a self signed server certificate (cert.pem) and need to enable it for SSL sockets in an Android application. Ideally I'd like to package the code as .jar file and not need an external certificate file (i.e. include it into the code).</p>
  
  <p>With this code I can accept all certificates, which is not what I want:</p>
  
  <pre><code>SSLContext sc = SSLContext.getInstance("TLS");
  sc.init(null, new TrustManager [] { new MyTrustManager() }, new SecureRandom());
  </code></pre>
  
  <p>Do I need to add the certificate to a custom KeyManager or the custom TrustManager? </p>
  
  <p>One problem I've encountered is that Android does not accept JKS keystores (KeyStore.getDefaultType() returns "BKS"): "<i>java.security.KeyStoreException: KeyStore JKS implementation not found</i>"</p>
  
  <p>Any ideas how to proceed would be highly appreciated!</p>