I've a byte[] of certificate data and I want to change this byte[] type to Certificate type. How can I achieve this?
Now I used CertificateFactory.generateCertificate(InputStream inStream).
byte[] csr = getCSR(cn, ou, org, loc, state, country,email);
CertificateFactory cf = CertificateFactory.getInstance("X.509");
ByteArrayInputStream bais = new ByteArrayInputStream(csr);
Certificate certificate = cf.generateCertificate(bais);
But Error occurred Certificate certificate = cf.generateCertificate(bais); at this line.
Error : java.security.cert.CertificateParsingException: java.io.IOException: ObjectIdentifier() -- data isn't an object ID (tag = 49)
Why this error occurred? What wrong in this code? Please explain me. Thanks.
You can use CertificateFactory.generateCertificate(InputStream inStream) to generate a Certificate.
Here is an example which generates an X509 Certificate:
CertificateFactory cf = CertificateFactory.getInstance("X.509");
Certificate certificate = cf.generateCertificate(new ByteArrayInputStream(buf));
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