Merge remote-tracking branch 'origin/dev-shangqing' into dev-shangqing
# Conflicts: # DProto/8003.xml
This commit is contained in:
@@ -2,6 +2,7 @@ package com.sunyard.util;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import com.sunyard.RetWrap;
|
||||
import com.sunyard.SydApiException;
|
||||
import com.sunyard.constant.CertUsage;
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
import sun.misc.BASE64Encoder;
|
||||
@@ -78,7 +79,7 @@ public class CertUtil {
|
||||
* @param cert 证书 base64 字符
|
||||
* @return true 国密, false 非国密
|
||||
*/
|
||||
public static boolean isSM2Cert(String cert) throws CertificateException, NoSuchProviderException {
|
||||
public static boolean isSM2Cert(String cert) {
|
||||
String pemCert;
|
||||
if(cert.contains("-----BEGIN CERTIFICATE-----")){
|
||||
pemCert =cert;
|
||||
@@ -87,7 +88,12 @@ public class CertUtil {
|
||||
String end_cert = "\n-----END CERTIFICATE-----";
|
||||
pemCert = cert_begin + cert + end_cert;
|
||||
}
|
||||
X509Certificate certificate = convertToX509Cert(pemCert);
|
||||
X509Certificate certificate = null;
|
||||
try {
|
||||
certificate = convertToX509Cert(pemCert);
|
||||
} catch (Exception e) {
|
||||
throw new SydApiException( 0xC101, e );
|
||||
}
|
||||
String signAlg = certificate.getSigAlgName();
|
||||
return signAlg.toUpperCase().indexOf("SM2") >= 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user