public static KeyStore createRootCertificateKeyStore(String keyStoreType,X509Certificate certificate,String privateKeyAlias,PrivateKey privateKey,String privateKeyPassword,String provider){
  if (privateKeyPassword == null) {
    throw new IllegalArgumentException("Must specify a KeyStore password");
  }
  KeyStore newKeyStore=KeyStoreUtil.createEmptyKeyStore(keyStoreType,provider);
  try {
    newKeyStore.setKeyEntry(privateKeyAlias,privateKey,privateKeyPassword.toCharArray(),new Certificate[]{certificate});
  }
 catch (  KeyStoreException e) {
    throw new KeyStoreAccessException("Unable to store certificate and private key in KeyStore",e);
  }
  return newKeyStore;
}

public static KeyStore createRootCertificateKeyStore ( String keyStoreType , X509Certificate certificate , String privateKeyAlias , PrivateKey privateKey , String privateKeyPassword , String provider ) { if ( privateKeyPassword == null ) { throw new IllegalArgumentException ( "Must specify a KeyStore password" ) ; } KeyStore newKeyStore = KeyStoreUtil . createEmptyKeyStore ( keyStoreType , provider ) ; try { newKeyStore . setKeyEntry ( privateKeyAlias , privateKey , privateKeyPassword . toCharArray ( ) , new Certificate [ ] { certificate } ) ; } catch ( KeyStoreException e ) { throw new KeyStoreAccessException ( "Unable to store certificate and private key in KeyStore" , e ) ; } return newKeyStore ; }
creates a new keystore containing the specified root certificate and private key .
