public static KeyPair generateKeyPair(String algorithm) throws NoSuchAlgorithmException {
        KeyPairGenerator keyGen = KeyPairGenerator.getInstance(algorithm);
        keyGen.initialize(algorithm.equals("EC") ? 256 : 2048);
        return keyGen.genKeyPair();
    }
Generate a signed certificate. Self-signed, if no issuer and parentKeyPair are supplied

@param dn The distinguished name of this certificate
@param keyPair A key pair
@param daysBeforeNow how many days before now the Certificate is valid for
@param daysAfterNow how many days from now the Certificate is valid for
@param issuer The issuer who signs the certificate. Leave null if you want to generate a root
       CA.
@param parentKeyPair The key pair of the issuer. Leave null if you want to generate a root
       CA.
@param algorithm the signing algorithm, eg "SHA1withRSA"
@return the signed certificate
@throws CertificateException
clients/src/test/java/org/apache/kafka/test/TestSslUtils.java