java如何生成.pfx文件?java语言可以生成pfx文件吗?
1个回答
展开全部
/**
* 证书私钥存储设施
*
* @param alias
* KeyStore别名
* @param key
* 密钥(这里是私钥)
* @param password
* 保存密码
* @param chain
* 证书链
* @param filePath
* PFX文件路径
* @throws KeyStoreException
* @throws NoSuchAlgorithmException
* @throws CertificateException
* @throws IOException
*/
private void createKeyStore(String alias, Key key, char[] password,
Certificate[] chain, String filePath) throws KeyStoreException,
NoSuchAlgorithmException, CertificateException, IOException {
KeyStore keyStore = KeyStore.getInstance("pkcs12");
keyStore.load(null, password);
keyStore.setKeyEntry(alias, key, password, chain);
FileOutputStream fos = new FileOutputStream(filePath);
keyStore.store(fos, password);
fos.close();
}
* 证书私钥存储设施
*
* @param alias
* KeyStore别名
* @param key
* 密钥(这里是私钥)
* @param password
* 保存密码
* @param chain
* 证书链
* @param filePath
* PFX文件路径
* @throws KeyStoreException
* @throws NoSuchAlgorithmException
* @throws CertificateException
* @throws IOException
*/
private void createKeyStore(String alias, Key key, char[] password,
Certificate[] chain, String filePath) throws KeyStoreException,
NoSuchAlgorithmException, CertificateException, IOException {
KeyStore keyStore = KeyStore.getInstance("pkcs12");
keyStore.load(null, password);
keyStore.setKeyEntry(alias, key, password, chain);
FileOutputStream fos = new FileOutputStream(filePath);
keyStore.store(fos, password);
fos.close();
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询