开发者

how to access android app's certificate from inside the app?

开发者 https://www.devze.com 2023-02-03 14:17 出处:网络
Im trying to access the certificate/signature from inside an android app, so that I can do something with the certificate.

Im trying to access the certificate/signature from inside an android app, so that I can do something with the certificate. I googled a bit and found the code below:

Class c =  getClass();
ProtectionDomain pd = c.getProtectionDomain();
CodeSource cs = pd.getCodeSource();
Certificate[] signingCerti开发者_如何转开发ficates = cs.getCertificates();
String st = signingCertificates[0].toString();

but c.getProtectionDomain() returns null.

anyone can help? many thanks.


Take a look at Android sources:

frameworks/base/core/java/android/content/pm/PakcageParser.java
frameworks/base/core/java/android/content/pm/Signature.java

You can perform the same on your app's own .apk.

0

精彩评论

暂无评论...
验证码 换一张
取 消