How can I add trust store in SSLSocketFactory in Android?
<p><br>
I'm writing an Android's app with SSL connection (not HTTP). I read a lot of tutorials about HTTPS in Android but it keeping product error "SSL socket factory is abstract cannot be instantiated." with <code>SSLSocketFactory sf = new SSLSocketFactory(truststore)</code>. <br>
My question is: How can I add key store to Android?.<br>
This is my example:<br>   </p>

<pre><code>public void run() {
 try {
      KeyStore trusted = KeyStore.getInstance("BKS");
      InputStream in = context.getResources().openRawResource(R.raw.keystore);
       try {
           trusted.load(in, "1234567".toCharArray());
           SSLSocketFactory sSLSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault(); // &lt;&lt;&lt;&lt;&lt; Line 40
           SSLSocket sslSocket = (SSLSocket) sSLSocketFactory.createSocket("10.0.2.2", 9998);
           sslSocket.startHandshake();
           Log.i("SSLsocket", "true");
            } finally {
                in.close();
            }    
        } catch (Exception e) {
            throw new AssertionError(e);
        }
    }

Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
                      at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:322)
                      at com.example.begood.voip.SSlconnection.run(SSlconnection.java:40)
</code></pre>