Android API cannot get X509Certificate
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.
精彩评论