我目前正在使用 bouncycastle 1.48 创建属性证书请求。由于 API 发生了一些变化(而且我是这方面的初学者)我无法为创建的请求添加属性我当前的代码是
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
keyGen.initialize(512);
KeyPair rsaKey = keyGen.generateKeyPair();
PrivateKey privateKey = rsaKey.getPrivate();
PublicKey publicKey = rsaKey.getPublic();
System.out.println(privateKey.getEncoded());
System.out.println(publicKey.getEncoded());
ContentSigner sigGen = new JcaContentSignerBuilder("SHA1withRSA").build(privateKey);
AlgorithmIdentifier rsaEncryption = new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, null);
SubjectPublicKeyInfo publicKeyInfo = new SubjectPublicKeyInfo(rsaEncryption, publicKey.getEncoded());
Date startDate = new Date(System.currentTimeMillis() - 24 * 60 * 60 * 1000);
Date endDate = new Date(System.currentTimeMillis() + 365 * 24 * 60 * 60 * 1000);
X500NameBuilder nameBuilder = new X500NameBuilder();
nameBuilder.addRDN(BCStyle.CN, "test request");
nameBuilder.addRDN(BCStyle.C, "UK");
nameBuilder.addRDN(BCStyle.E,"qwerasd@gmail.com");
nameBuilder.addRDN(BCStyle.GENDER,"M");
X500Name name = nameBuilder.build();
PKCS10CertificationRequestBuilder genReq = new PKCS10CertificationRequestBuilder(name,publicKeyInfo);
PKCS10CertificationRequest request = genReq.build(sigGen);
PEMWriter pemWriter = new PEMWriter(new FileWriter(new File("C:\\certs\\request.txt")));
pemWriter.writeObject(request);
pemWriter.flush();
我的问题是 - addAttribute 方法的正确语法应该如何?提前致谢