public CertificateMaterial generate() {
    KeyPair keyPair = generateKeyPair("RSA");
    PrivateKey privateKey;
    X509Certificate issuerCertificate = null;

    if (issuer == null) {
      privateKey = keyPair.getPrivate();
    } else {
      privateKey = issuer.getPrivateKey();
    }

    X509Certificate cert = generate(keyPair.getPublic(), privateKey);

    if (issuer != null) {
      issuerCertificate = issuer.getCertificate();
    }

    return new CertificateMaterial(cert, keyPair, issuerCertificate);
  }
Class which allows easily building certificates. It can also be used to build
Certificate Authorities. The class is intended to be used in conjunction with {@link CertStores}
to facilitate building key and trust stores.
geode-junit/src/main/java/org/apache/geode/cache/ssl/CertificateBuilder.java