我目前正在创建使用BouncyCastle的1.48属性证书请求。 因为有在API的一些变化(我在这件事情初学者)我unnable添加属性创建要求我当前的代码是
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方法? 提前致谢