0

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?

wake-0
  • 3,918
  • 5
  • 28
  • 45
  • What version are you using? I'm using 1.57 (bcprov-jdk15on-1.57) and the source code says: `@deprecated use org.bouncycastle.cert.X509AttributeCertificateHolder` –  Jun 13 '17 at 14:08
  • @Hugo I am using 1.56 at the moment. The problem is still that I don't want to send the certificate holder and even if I use the `X509AttrCertParser`with the `engineRead()` method a `X509V2AttributeCertificate` is returned (see https://stackoverflow.com/questions/6370368/bouncycastle-x509certificateholder-to-x509certificate/8960906#8960906) – wake-0 Jun 16 '17 at 08:45

0 Answers0