I'm currently working on creating attribute certificate requests using bouncycastle 1.48. Since there were some changes in API (and I'm beginner in this matter) I am unnable to add attributes to created request My current code is
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();
My question is - how should proper syntax looks like for addAttribute method? Thanks in advance