Here you can find the source of getKeyStore(char[] password)
public static KeyStore getKeyStore(char[] password) throws KeyStoreException, CertificateException
//package com.java2s; import java.io.*; import java.security.*; import java.security.cert.*; public class Main { private static final String KEY_STORE_TYPE = "JKS"; public static KeyStore getKeyStore(char[] password) throws KeyStoreException, CertificateException { KeyStore ks = null;/*from w w w.j av a 2 s. com*/ try { ks = getKeyStore(null, password, null, null, null); } catch (IOException ioe) { // Should not be thrown since no file is being loaded } return ks; } public static KeyStore getKeyStore(File keyFile, char[] password) throws KeyStoreException, CertificateException, IOException { return getKeyStore(keyFile, password, null, null, null); } public static KeyStore getKeyStore(char[] password, String keyAlias, PrivateKey privateKey, X509Certificate[] certList) throws KeyStoreException, CertificateException { KeyStore ks = null; try { ks = getKeyStore(null, password, keyAlias, privateKey, certList); } catch (IOException ioe) { // Should not be thrown since no file is being loaded } return ks; } public static KeyStore getKeyStore(File keyFile, char[] password, String keyAlias, PrivateKey privateKey, X509Certificate[] certList) throws KeyStoreException, CertificateException, IOException { KeyStore store = null; InputStream is = null; try { if (keyFile != null) { try { is = new FileInputStream(keyFile); } catch (FileNotFoundException fnfe) { // it's okay, just use null } } store = KeyStore.getInstance(KEY_STORE_TYPE); store.load(is, password); if (keyAlias != null && privateKey != null) { store.setKeyEntry(keyAlias, privateKey, password, certList); } } catch (NoSuchAlgorithmException nsae) { // Leave store as null } finally { if (is != null) { is.close(); } } return store; } }