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();
if (names.size() != 1)
{