how to access android app's certificate from inside the app?
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.
精彩评论