Vector<DERObjectIdentifier> oidvec = new Vector<DERObjectIdentifier>();
oidvec.add(X509Extensions.SubjectAlternativeName);
Vector<X509Extension> valuevec = new Vector<X509Extension>();
valuevec.add(new X509Extension(false, new DEROctetString(extOut.toByteArray())));
X509Extensions exts = new X509Extensions(oidvec, valuevec);
extensionattr.add(new DERSet(exts));
// Complete the Attribute section of the request, the set (Attributes)
// contains one sequence (Attribute)
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(new DERSequence(extensionattr));
DERSet attributes = new DERSet(v);
// Create PKCS#10 certificate request
PKCS10CertificationRequest req = new PKCS10CertificationRequest("SHA1WithRSA", new X509Name("C=SE,CN=extoverride"), rsakeys.getPublic(), attributes,
rsakeys.getPrivate());
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
DEROutputStream dOut = new DEROutputStream(bOut);