I use the X509V2AttributeCertificate
from Bouncycastle. The problem is, that it is deprecated but I do not find any replacement for the exisiting (deprecated) code. Does someone know the new way?
My way: I use a X509AttributeCertificateHolder
, this holder contains the certificate. When I communicate with a client I don't want to send the holder instead I want to send the X509V2AttributeCertificate
(for me it seems to be the cleaner code). To do this I use the following code (the client is the file):
X509V2AttributeCertificate certitificate = new X509V2AttributeCertificate(att.getEncoded());
// Store to file (send the byte[] to the client)
String fileName = "test";
FileOutputStream fos = new FileOutputStream(fileName);
fos.write(certitificate.getEncoded());
fos.close();
// Read from file (decode the received certificate)
byte[] readCertificate = Files.readAllBytes(new File(fileName).toPath());
X509V2AttributeCertificate decodedCertificate = new X509V2AttributeCertificate(readCertificate);
How should the X509V2AttributeCertificate
be replaced?