there. I need to establish https connection with https://free.temafon.ru but I've got CertPathValidatorException on Android 2.3 and below. What have I done.
- Grab all certs from https://free.temafon.ru with Firefox.
- Import certs in keystore in sequence from temefon certificate to root certificate.
Init ssl context:
final KeyStore keystore = KeyStore.getInstance("BKS");
keystore.load(getResources().openRawResource(R.raw.temafon), "W0d3Uoa5PkED".toCharArray()); final TrustManager trustManager = new TemafonTrustManager(keystore); final SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, new TrustManager[] { trustManager }, null); HttpsURLConnection.setDefaultSSLSocketFactory(sslContext .getSocketFactory());
Here, I use custom TrustManager, because server sends certs in wrong order.
This code works fine on Android 4.0, but failed on 2.3 with java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
What I'm doing whrong?
I've created a test project, which can be found here.