mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-10-04 19:42:01 +08:00
keyChain & identity添加部分注释
This commit is contained in:
1 parent
dbeb27abe7
commit
d36723b068
14 files changed
+383
-47
No files matched your search
@@ -125,10 +125,11 @@ public class CertUtils {
|
||||
* 将TbsCertificate类型实例转化为字节流
|
||||
* @param tbsCertificate
|
||||
* @return byte[]
|
||||
* @throws CertException
|
||||
* @author hongyu guo
|
||||
* @date 2021/3/7
|
||||
**/
|
||||
public static byte[] serialization(TbsCertificate tbsCertificate){
|
||||
public static byte[] serialization(TbsCertificate tbsCertificate) throws CertException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
byte[] bytesOfCertJson;
|
||||
try {
|
||||
@@ -137,17 +138,18 @@ public class CertUtils {
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new byte[0];
|
||||
throw new CertException("tbsCertificate serialization failed");
|
||||
}
|
||||
|
||||
/**
|
||||
* 将InnerCertificate类型实例转化为字节流
|
||||
* @param innerCertificate
|
||||
* @return byte[]
|
||||
* @throws CertException
|
||||
* @author hongyu guo
|
||||
* @date 2021/3/7
|
||||
**/
|
||||
public static byte[] serialization(InnerCertificate innerCertificate){
|
||||
public static byte[] serialization(InnerCertificate innerCertificate) throws CertException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
byte[] bytesOfCertJson;
|
||||
try {
|
||||
@@ -156,7 +158,7 @@ public class CertUtils {
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new byte[0];
|
||||
throw new CertException("innerCertificate serialization failed");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -280,12 +282,15 @@ public class CertUtils {
|
||||
* @author hongyu guo
|
||||
* @date 2021/3/7
|
||||
**/
|
||||
public static Certificate fromPem(String pemString, byte[] passwd, int symAlgoMode) throws CertException, BadPaddingException, NoSuchPaddingException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IllegalBlockSizeException, NoSuchProviderException, InvalidKeyException {
|
||||
public static Certificate fromPem(String pemString, byte[] passwd, int symAlgoMode)
|
||||
throws CertException, BadPaddingException, NoSuchPaddingException,
|
||||
InvalidAlgorithmParameterException, NoSuchAlgorithmException,
|
||||
IllegalBlockSizeException, NoSuchProviderException, InvalidKeyException {
|
||||
if(pemString == null || pemString.equals("")){
|
||||
throw new CertException("pem串为空");
|
||||
}
|
||||
byte[] bytesOfPem = Base64.getDecoder().decode(pemString);
|
||||
byte[] bytesOfCert = new byte[0];
|
||||
byte[] bytesOfCert;
|
||||
if(passwd != null && passwd.length > 0){
|
||||
byte[] sm4Key = KeyUtils.get16bytePasswd(passwd);
|
||||
switch (symAlgoMode){
|
||||
@@ -295,6 +300,8 @@ public class CertUtils {
|
||||
case Common.SM4ECB:
|
||||
bytesOfCert = SM4.decrypt_ECB_Padding(sm4Key, bytesOfPem);
|
||||
break;
|
||||
default:
|
||||
throw new CertException("未知的对称加密算法");
|
||||
}
|
||||
} else {
|
||||
bytesOfCert = bytesOfPem;
|
||||
|
||||
Reference in new issue
Block a user