Did you spot the difference in the title? (for me, it took some time)
So I used bouncy castle with connection to java.security.cert.X509Certificate
in order
to create certificates. Now I'm looking for a way to create a java.security.cert.X509Certificate
from raw bytes. I haven't any method to do this in
java.security.cert.X509Certificate
but there is one(the getInstance static method) in
javax.security.cert.X509Certificate
.
The problem is I cannot cast a javax.security.cert.X509Certificate
to java.security.cert.X509Certificate
.
Any ideas on what to do, to transform raw bytes into a java.security.cert.X509Certificate
?
Also, what's the differences between the one abstract class and the other class? Why does java has two of them with different functionality?
The javax version is deprecated. Use CertificateFactory to generate a certificate from raw bytes. There is an example in the javadocs.
This happened for me because I am using j2se but imported javax classes. Certificate and X509Certficate classes exists both in J2SE and in J2EE.
Imports in J2SE - Not javax.security...
import java.security.cert.Certificate;
Not these.