List of usage examples for java.security KeyStore setKeyEntry
public final void setKeyEntry(String alias, byte[] key, Certificate[] chain) throws KeyStoreException
From source file:com.aqnote.shared.cryptology.cert.util.KeyStoreUtil.java
public static KeyStore createPCSK12KeyStore(String alias, Key key, char[] pwd, Certificate[] chain) throws CertException { try {// w w w . j a v a 2 s.c om KeyStore keyStore = KeyStore.getInstance(PKCS12_STORE_TYPE); keyStore.load(null, pwd); if (pwd == null) { keyStore.setKeyEntry(alias, key.getEncoded(), chain); } else { keyStore.setKeyEntry(alias, key, pwd, chain); } return keyStore; } catch (KeyStoreException e) { throw new CertException(e); } catch (NoSuchAlgorithmException e) { throw new CertException(e); } catch (CertificateException e) { throw new CertException(e); } catch (IOException e) { throw new CertException(e); } }