KeyPair pair = keyGen.generateKeyPair();
Vector oids = new Vector();
Vector values = new Vector();
oids.add(X509Extensions.BasicConstraints);
values.add(new X509Extension(true, new DEROctetString(new BasicConstraints(true))));
oids.add(X509Extensions.KeyUsage);
values.add(new X509Extension(true, new DEROctetString(
new KeyUsage(KeyUsage.keyCertSign | KeyUsage.cRLSign))));
SubjectKeyIdentifier subjectKeyIdentifier = new SubjectKeyIdentifierStructure(pair.getPublic());
X509Extension ski = new X509Extension(false, new DEROctetString(subjectKeyIdentifier));
oids.add(X509Extensions.SubjectKeyIdentifier);
values.add(ski);
Attribute attribute = new Attribute(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest,
new DERSet(new X509Extensions(oids, values)));