X509 certificate in java
I am reading a certificate from a NFC tag and its value is in List(byte).
Once I read the byte I want to create a X509 certificate to access all the
attributes of the certificate. Here is what I have so far:
SignatureRecord firma = (SignatureRecord)record;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(firma.getSignature());
byte[] bytes = bos.toByteArray();
System.out.println(Arrays.toString(bytes));
FileOutputStream sigfos = new FileOutputStream("cer.cert");
sigfos.write(bytes);
sigfos.close();
FileInputStream fr = new FileInputStream("cer.cert");
CertificateFactory cf = CertificateFactory.getInstance("X509");
X509Certificate c = (X509Certificate)cf.generateCertificate(fr);
System.out.println("\tCertificate issued by: " + c.getIssuerDN());
No comments:
Post a Comment