@Test
public void testGenerateCertificate() throws Exception
{

    String rootDn = RSAUtil.buildDN("GB", "SomeState", "SomeLocality", "MyOrg", "Basement", "testing.root");
    // generate our root cert
    CertificatePair root = RSAUtil.generateCertificate(rootDn, SerialNum.randomSerialNum(), 365 * 15, 512, KeyType.CA, null);
    assertThat(root, is(notNullValue()));
    assertThat(root.getCertificate(), is(notNullValue()));
    assertThat(root.getKey(), is(notNullValue()));
    System.out.println("Root:\n" + root);
    // generate a server cert
    String serverDn = RSAUtil.buildDN("GB", "SomeState", "SomeLocality", "MyOrg", "Basement", "testing.server");
    CertificatePair server = RSAUtil.generateCertificate(serverDn, SerialNum.randomSerialNum(), 365 * 15, 512, KeyType.SERVER, root);
    assertThat(server, is(notNullValue()));
    assertThat(server.getCertificate(), is(notNullValue()));
    assertThat(server.getKey(), is(notNullValue()));
    server.getCertificate().verify(root.getCertificate().getPublicKey());
    System.out.println("Server:\n" + server);
    
}