Fixed Android API version detection, load cacerts dir for API >= 14

This commit is contained in:
str4d
2014-03-07 08:27:14 +00:00
parent 8c820bb237
commit 2b0dfed012
2 changed files with 9 additions and 4 deletions

View File

@ -94,9 +94,14 @@ public class KeyStoreUtil {
success = loadCerts(new File(override), ks);
if (!success) {
if (SystemVersion.isAndroid()) {
// thru API 13. As of API 14 (ICS), the file is gone, but
// ks.load(null, pw) will bring in the default certs?
success = loadCerts(new File(System.getProperty("java.home"), "etc/security/cacerts.bks"), ks);
if (SystemVersion.getAndroidVersion() >= 14) {
try {
ks.load(null, DEFAULT_KEYSTORE_PASSWORD.toCharArray());
success = addCerts(new File(System.getProperty("java.home"), "etc/security/cacerts"), ks) > 0;
} catch (Exception e) {}
} else {
success = loadCerts(new File(System.getProperty("java.home"), "etc/security/cacerts.bks"), ks);
}
} else {
success = loadCerts(new File(System.getProperty("java.home"), "lib/security/jssecacerts"), ks);
if (!success)

View File

@ -47,7 +47,7 @@ public abstract class SystemVersion {
int sdk = 0;
if (_isAndroid) {
try {
Class<?> ver = Class.forName("android.os.Build.VERSION", true, ClassLoader.getSystemClassLoader());
Class<?> ver = Class.forName("android.os.Build$VERSION", true, ClassLoader.getSystemClassLoader());
Field field = ver.getField("SDK_INT");
sdk = field.getInt(null);
} catch (Exception e) {}