public static KeyPair generateKeyPair(String algorithm) throws NoSuchAlgorithmException {
    KeyPairGenerator keyGen = KeyPairGenerator.getInstance(algorithm);
    keyGen.initialize(1024);
    return keyGen.genKeyPair();
  }
Create a self-signed X.509 Certificate.
From http://bfo.com/blog/2011/03/08/odds_and_ends_creating_a_new_x_509_certificate.html.

@param dn the X.509 Distinguished Name, eg "CN(commonName)=Test, O(organizationName)=Org"
@param pair the KeyPair
@param days how many days from now the Certificate is valid for
@param algorithm the signing algorithm, eg "SHA1withRSA"
@param subjectAltNames the subject alternative names for which the Certificate is valid for
@return the self-signed certificate
@throws java.security.cert.CertificateException thrown if a security error or an IO error ocurred.
ambry-test-utils/src/main/java/com/github/ambry/commons/TestSSLUtils.java