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.
@param dn        the X.509 Distinguished Name, eg "CN=Test, L=London, C=GB"
@param pair      the KeyPair
@param days      how many days from now the Certificate is valid for
@param algorithm the signing algorithm, eg "SHA1withRSA"
@return the self-signed certificate
hbase-http/src/test/java/org/apache/hadoop/hbase/http/ssl/KeyStoreTestUtil.java