Java Bouncycastle:X509AttributeCertificate已弃用
我使用Bouncycastle提供的Java Bouncycastle:X509AttributeCertificate已弃用,java,bouncycastle,attributecertificate,Java,Bouncycastle,Attributecertificate,我使用Bouncycastle提供的X509v2Attribute证书。问题是,它已弃用,但我找不到任何替代现有(弃用)代码的方法。有人知道新方法吗 我的方式:我使用X509AttributeCertificateHolder,此持有者包含证书。当我与客户通信时,我不想发送持有者,而是想发送X509V2AttributeCertificate(对我来说,它似乎是更干净的代码)。为此,我使用以下代码(客户端就是文件): 应如何更换X509V2AttributeCertificate?我使用的是1.
X509v2Attribute证书。问题是,它已弃用,但我找不到任何替代现有(弃用)代码的方法。有人知道新方法吗
我的方式:我使用X509AttributeCertificateHolder
,此持有者包含证书。当我与客户通信时,我不想发送持有者,而是想发送X509V2AttributeCertificate
(对我来说,它似乎是更干净的代码)。为此,我使用以下代码(客户端就是文件):
应如何更换X509V2AttributeCertificate
?我使用的是1.57(bcprov-jdk15on-1.57),源代码是:@deprecated use org.bouncycastle.cert.X509AttributeCertificateHolder
@Hugo我目前使用的是1.56。问题仍然是,我不想发送证书持有者,即使我使用X509AttrCertParser
和engineRead()
方法,也会返回X509V2AttributeCertificate
(请参阅)
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);