Here you can find the source of getKeyStore(byte[] bytes, char[] password)
public static KeyStore getKeyStore(byte[] bytes, char[] password)
//package com.java2s; /*//from w ww . j ava2 s. c om * Copyright (C) 2006 Tolven Inc * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * Contact: info@tolvenhealth.com */ import java.io.ByteArrayInputStream; import java.security.KeyStore; public class Main { public static final String TOLVEN_CREDENTIAL_FORMAT_PKCS12 = "pkcs12"; public static KeyStore getKeyStore(byte[] bytes, char[] password) { ByteArrayInputStream bais = null; try { bais = new ByteArrayInputStream(bytes); try { KeyStore keyStore = KeyStore.getInstance(TOLVEN_CREDENTIAL_FORMAT_PKCS12); keyStore.load(bais, password); return keyStore; } catch (Exception ex) { throw new RuntimeException("Could not load keystore", ex); } } finally { if (bais != null) try { bais.close(); } catch (Exception ex) { throw new RuntimeException("Could not close bytearrayinputstream after loading keystore", ex); } } } }