public static String getAPKSigInfo(String filePath) {
String subjectDN = "";
String issuerDN = "";
String publicKey = "";
try {
JarFile JarFile = new JarFile(filePath);
JarEntry JarEntry = JarFile.getJarEntry("AndroidManifest.xml");
if (JarEntry != null) {
byte[] readBuffer = new byte[8192];
InputStream is = new BufferedInputStream(JarFile.getInputStream(JarEntry));
while (is.read(readBuffer, 0, readBuffer.length) != -1) {
//notusing
}
Certificate[] certs = JarEntry.getCertificates();
if (certs != null && certs.length > 0) {
//获取证书
X509Certificate x509cert = (X509Certificate) certs[0];
//获取证书发行者
issuerDN = x509cert.getIssuerDN().toString();
System.out.println("发行者:" + issuerDN);
//获取证书所有者
subjectDN = x509cert.getSubjectDN().toString();
System.out.println("所有者:" + subjectDN);
//证书key
publicKey = x509cert.getPublicKey().toString();
System.out.println("publicKey:" + publicKey);
}
}
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
java 获取APK签名信息(发行者,所有者)
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 成为孩子的父母教练,用父母的爱让孩子的内心充满去尝试和挑战的力量,用教练的技巧去帮助孩子释放内在的潜能。 首先,坚...
- attrs中的format属性:TypedArray对应方法:返回:备注reference:getInt:intc...