public static byte[] certToJavaTrustStoreBytes(X509Certificate cert, char[] keyPassword)
    throws IOException, GeneralSecurityException {
    KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
    return certToTrustStoreBytes(cert, keyPassword, trustStore);
  }
Encodes the given X509Certificate as a JKS TrustStore, optionally protecting the cert with a
password (though it's unclear why one would do this since certificates only contain public
information and do not need to be kept secret). Returns the byte array encoding of the trust
store, which may be written to a file and loaded to instantiate the trust store at a later
point or in another process.
@param cert        the certificate to serialize.
@param keyPassword an optional password to encrypt the trust store. If empty or null, the cert
                   will not be encrypted.
@return the serialized bytes of the JKS trust store.
hbase-common/src/test/java/org/apache/hadoop/hbase/io/crypto/tls/X509TestHelpers.java