private static KeyPair generateRsaKeyPair(int keySize) throws Exception {
        KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", "BC");
        kpg.initialize(keySize);
        return kpg.generateKeyPair();
    }
Helper method to generate RSA key pair using Bouncy Castle.
integration/logstash-plugins/logstash-output-vespa/src/main/java/org/logstashplugins/SelfSignedCertGenerator.java