mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
KeyUtil中的读取KeyStore文件的方法增加全局Provider
This commit is contained in:
parent
b78657f67f
commit
05c32a8f46
@ -11,6 +11,7 @@
|
||||
* 【core 】 HtmlUtil中escape方法,增加不断开空格(nbsp)转译,防止xss攻击(pr#2755@Github)
|
||||
* 【extra 】 修正sftp.cd方法 方法注释和实际效果不符(issue#2758@Github)
|
||||
* 【core 】 修改PhoneUtil容易歧义的注释(issue#I63GWK@Gitee)
|
||||
* 【crypto】 KeyUtil中的读取KeyStore文件的方法增加全局Provider(issue#I6796G@Gitee)
|
||||
*
|
||||
### 🐞Bug修复
|
||||
* 【json 】 修复普通byte数组转JSONArray时的异常(pr#875@Gitee)
|
||||
|
@ -745,9 +745,8 @@ public class KeyUtil {
|
||||
* @return {@link KeyStore}
|
||||
*/
|
||||
public static KeyStore readKeyStore(String type, InputStream in, char[] password) {
|
||||
KeyStore keyStore;
|
||||
final KeyStore keyStore = getKeyStore(type);
|
||||
try {
|
||||
keyStore = KeyStore.getInstance(type);
|
||||
keyStore.load(in, password);
|
||||
} catch (Exception e) {
|
||||
throw new CryptoException(e);
|
||||
@ -755,6 +754,21 @@ public class KeyUtil {
|
||||
return keyStore;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取{@link KeyStore}对象
|
||||
*
|
||||
* @param type 类型
|
||||
* @return {@link KeyStore}
|
||||
*/
|
||||
public static KeyStore getKeyStore(final String type) {
|
||||
final Provider provider = GlobalBouncyCastleProvider.INSTANCE.getProvider();
|
||||
try {
|
||||
return null == provider ? KeyStore.getInstance(type) : KeyStore.getInstance(type, provider);
|
||||
} catch (final KeyStoreException e) {
|
||||
throw new CryptoException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从KeyStore中获取私钥公钥
|
||||
*
|
||||
@ -993,6 +1007,7 @@ public class KeyUtil {
|
||||
|
||||
/**
|
||||
* 将密钥编码为Base64格式
|
||||
*
|
||||
* @param key 密钥
|
||||
* @return Base64格式密钥
|
||||
* @since 5.7.22
|
||||
|
Loading…
x
Reference in New Issue
Block a user