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?
public abstract class X509Certificate extends Certificate. Abstract class for X. 509 v1 certificates. This provides a standard way to access all the version 1 attributes of an X. 509 certificate.
The Java Certificate class ( java. security. cert. Certificate ) represents a cryptographic identity certificate. A Java Certificate class instance contains name plus other details of the entity it identifies, plus possibly a digital signature from a Certificate Authority (CA).
This class is an abstraction for certificates that have different formats but important common uses. For example, different types of certificates, such as X. 509 and PGP, share general certificate functionality (like encoding and verifying) and some types of information (like a public key).
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.
import java.security.KeyStore; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate;
Not these.
import javax.security.cert.X509Certificate;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With