I've create a hybrid web application using SAP Mobile Services.
This application (.apk
) must run only if there is a specific certificate installed on the Android device. Otherwise, it should not run.
Any ideas how to solve this?
I've create a hybrid web application using SAP Mobile Services.
This application (.apk
) must run only if there is a specific certificate installed on the Android device. Otherwise, it should not run.
Any ideas how to solve this?
in MainActivity.java add this code:
boolean isCertExist = false;
try
{
KeyStore ks = KeyStore.getInstance("AndroidCAStore");
if (ks != null)
{
ks.load(null, null);
Enumeration aliases = ks.aliases();
while (aliases.hasMoreElements())
{
String alias = (String) aliases.nextElement();
java.security.cert.X509Certificate cert = (java.security.cert.X509Certificate) ks.getCertificate(alias);
System.out.println(cert.getIssuerDN().getName());
if (cert.getIssuerDN().getName().contains("<STRING CERT>"))
{
isCertExist = true;
break;
}
}
}