private String[] getCertMsg(String packageName){
String[] certMsg = new String[2];
PackageInfo pis;
try {
certMsg[1] = cert.getSubjectDN().toString();
DebugUtil.i("IssuerDN: " + certMsg[0] + " SubjectDN: " + certMsg[1]);
} catch (CertificateException e) {
// TODO Auto-generated catch block
DebugUtil.e("CertificateException" + e.getMessage());
} catch (Exception e) {
// TODO Auto-generated catch block
DebugUtil.e("Exception: " + e.getMessage());
}
return certMsg;
}
String[] certMsg = new String[2];
PackageInfo pis;
try {
pis = mContext.getPackageManager().getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
Signature[] sigs = pis.signatures; //签名CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
//获取证书
X509Certificate cert = (X509Certificate) certFactory.generateCertificate(new ByteArrayInputStream(sigs[0].toByteArray()));
//获取证书发行者 可根据证书发行者来判断该应用是否被二次打包(被破解的应用重新打包后,签名与原包一定不同,据此可以判断出该应用是否被人做过改动)
certMsg[1] = cert.getSubjectDN().toString();
DebugUtil.i("IssuerDN: " + certMsg[0] + " SubjectDN: " + certMsg[1]);
} catch (CertificateException e) {
// TODO Auto-generated catch block
DebugUtil.e("CertificateException" + e.getMessage());
} catch (Exception e) {
// TODO Auto-generated catch block
DebugUtil.e("Exception: " + e.getMessage());
}
return certMsg;
}