public static byte[] certAndPrivateKeyToJavaKeyStoreBytes(X509Certificate cert,
    PrivateKey privateKey, char[] keyPassword) throws IOException, GeneralSecurityException {
    KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
    return certAndPrivateKeyToBytes(cert, privateKey, keyPassword, keyStore);
  }
Encodes the given X509Certificate and private key as a JKS KeyStore, optionally protecting the
private key (and possibly the cert?) with a password. Returns the byte array encoding of the
key store, which may be written to a file and loaded to instantiate the key store at a later
point or in another process.
@param cert        the X509 certificate to serialize.
@param privateKey  the private key to serialize.
@param keyPassword an optional key password. If empty or null, the private key will not be
                   encrypted.
@return the serialized bytes of the JKS key store.
hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/tls/X509TestHelpers.java