Merge remote-tracking branch 'origin/dev-shangqing' into dev-shangqing
# Conflicts: # DProto/8003.xml
This commit is contained in:
@@ -91,6 +91,9 @@ public class SydApiException extends RuntimeException{
|
||||
msg = "证书删除错误";
|
||||
break;
|
||||
|
||||
case 0xC101 :
|
||||
msg = "证书识别异常";
|
||||
break;
|
||||
default:
|
||||
msg = "未定义的错误";
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -484,12 +484,15 @@ public class SydApi4j implements SydApi {
|
||||
PacketSN sn = PacketSN.gen();
|
||||
packet.put("header", sn.getSn().array());
|
||||
if (rFlag == 1) {
|
||||
// MD5
|
||||
data.put("rFlag", 'M');
|
||||
}
|
||||
if (rFlag == 2) {
|
||||
// SHA-1
|
||||
data.put("rFlag", 'S');
|
||||
}
|
||||
if (rFlag == 3) {
|
||||
// SHA-256
|
||||
data.put("rFlag", 'R');
|
||||
}
|
||||
data.put("signatureDataType$option", 1);
|
||||
@@ -1366,6 +1369,7 @@ public class SydApi4j implements SydApi {
|
||||
List<String> partcerts = (List<String>)partCert.get("certDNs");
|
||||
m_certs.addAll(partcerts);
|
||||
}
|
||||
|
||||
return m_certs;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user