开发者

Android API cannot get X509Certificate

开发者 https://www.devze.com 2023-04-12 11:40 出处:网络
I have been trying to get subject alternative names from an X509Certificate, but it seems cert.getSubjectAlternativeNames() does not work in Android, which returns null.

I have been trying to get subject alternative names from an X509Certificate, but it seems cert.getSubjectAlternativeNames() does not work in Android, which returns null. However, when I use cert.getExtensionValue("2.5.29.17") to e开发者_JAVA百科xtract subject alternative names, the names DO exist and I can parse it byte by byte.

Btw, I am sure my PKCS12 certificate is valid, because I can use getSubjectAlternativeNames() and get the correct result in Java program.

Does any body know how to use getSubjectAlternativeNames() in Android correctly or I miss some configuration in Android?

Thanks Aoting


Try using org.bouncycastle.x509.extension.X509ExtensionUtil.getSubjectAlternativeNames(X509Certificate cert) as a workaround. If the extension is there, and assuming the bug is not in X509ExtensionUtil itself, but in X509Certificate, it should work.


It seems that certificate does not contain SubjectAltName extension. Also on which version of Android you are trying this ? There is already an issue reported to Google around this, which see to have been resolved in Froyo.

0

精彩评论

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