certGen.addExtension("2.5.29.37", true,
new DERSequence(KeyPurposeId.anyExtendedKeyUsage));
certGen.addExtension(Extension.subjectAlternativeName.getId(), true,
new GeneralNames(new GeneralName(GeneralName.rfc822Name, "test@test.test")));
certGen.addExtension(Extension.issuerAlternativeName, false,
new GeneralNames(new GeneralName(GeneralName.directoryName, new X500Name("O=Test, OU=Testing, C=AU"))));
X509Certificate baseCert = certGen.generate(privKey, "BC");
Collection names = baseCert.getSubjectAlternativeNames();