Smack 4.1 for Android(sdk >= 23): connect with TLS,how to use system trusted credentials?

Hi, I have trouble about TLS connect in Android , My server has a certificate issued by GlobalSign and I find GlobalSign has a root CA in Android Trusted credentials( Setting - Privacy - Credential storage). so I need use Android System trusted credentials to verify the server’s certificate. Here is my config:

configBuilder.setSecurityMode(SecurityMode.ifpossible);

if (Build.VERSION.SDK_INT >= 23){

//TODO: how to config when android sdk >= 23 ?

}

else if (Build.VERSION.SDK_INT >= 14) {

configBuilder.setKeystoreType(“AndroidCAStore”);

configBuilder.setKeystorePath(null);

} else {

configBuilder.setKeystoreType(“BKS”);

String path = System.getProperty(“javax.net.ssl.trustStore”);

if (path == null)

path = System.getProperty(“java.home”) + File.separator + “etc”

  • File.separator + “security” + File.separator
  • “cacerts.bks”;

configBuilder.setKeystorePath(path);

}

I don’t know how to config when up android 23.

Smack 4.1 has SSLContext to config, does SSLContext can solve this problem? anyone can help me? Thanks!