API接口文档

证书签发-个人证书

传入身份信息,进行证书的申请和签发。

一、公共参数

二、请求参数(请求方式为 post)

名称 类型 是否必须 描述
request PersonalIssueRequest 个人高级证书签发请求

PersonalIssueRequest 说明:

名称 类型 是否必须 描述
personalSeniorCertificate PersonalSeniorCertificate 个人高级证书实体信息
pkCS10 String 用于制作证书的 pkCS10
extensions Map 扩展属性
agentInfo AgentInfo 经办人信息(非合约用户必传经办人手机号)
password String 交易密码
extend String 预留信息
keyId String keyId

PersonalSeniorCertificate 说明:

名称 类型 是否必须 描述
idType IdType 证件类型
idNumber String 证件号,需要与证件类型匹配
phoneNumber String 联系号码
ownerName String 证书持有者姓名
commonName String 证书 CN 项,证书持有者名称
organization String 证书 O 项,证书所属组织
organizationUnit String 证书 OU 项,证书所属组织单元
country String 证书 C 项,国家,默认 CN
province String 证书 S 项,证书所属省
city String 证书 L 项,证书所属市
districtCounty String 证书所属区县
givenName String 名字,证书GIVENNAME项
email String 证书所属人邮箱
extraExtension List<Extension> 证书扩展项
medium String 介质信息
accountId String 交易账号

Extension 说明:

名称 类型 描述
oid String 扩展项oid值
value String 扩展项值
name String 扩展项名称

证件类型(IdType)说明:

名称 描述
ID 身份证
PASSPORT 护照
MILITARY_ID 军人身份证
BUSINESS_REGISTRATION_CERT 工商登记证
TAX_REGISTRATION_CERT 税务登记证
SHAREHOLDER_CODE_CERT 股东代码证
SOCIAL_SECURITY_CARD 社会保障卡
ARMED_POLICE 武装警察身份证件
HK_MACAU_PASSPORT 港澳居民往来内地通行证
TAIWAN_PASSPORT 台湾居民往来内地通行证
HOUSEHOLD_REGISTER 户口簿
TEMPORARY_ID 临时身份证
POLICE_CERT 警官证
PERMANENT_RESIDENCE_PERMIT 外国人永久居留证
GOVERNMENT_APPROVAL 政府批文
UNIFIED_SOCIAL_CERT 统一社会信用代码证
PRIVATE_NON_ENTERPRISE_CERT 民办非企业登记证书
CORPORATE_CERT 法人证书
OTHER 其他

经办人信息(AgentInfo) 说明:

名称 类型 是否必须 描述
agentName String 经办人姓名
agentId String 经办人身份证号
agentPhone String 经办人手机号码
agentEmail String 经办人邮箱
note String 经办人备注

代码实例:

public class PersonalCertSopApiTest {

/**
* 个人证书签发测试
*/
@Test
public void testIssue() throws Exception {
// 提供的服务地址map集合
HashMap<String, String> map = new HashMap<String, String>();
map.put("cip.api.gf.demo.smartcert.cn", "cn-beijing-1");
map.put("cip.api.gx.demo.smartcert.cn","cn-nanjing-1");
// 优先地域
String location = "cn-nanjing";
// 备用地域集合
List<String> reserveLocation = new ArrayList<String>();
reserveLocation.add("cn-beijing");
// 您的appKey
String appKey = "w8MuGC9C";
// 您的secretKey
String secretKey = "4wVznIMB";
// 构造接口实例
ApiClient apiClient = new DefaultApiClient(map, location, reserveLocation, appKey, secretKey);
PersonalCertSopApi personalCertSopApi = new PersonalCertSopApiImpl(apiClient);
//构造个人高级证书签发请求
PersonalIssueRequest request = new PersonalIssueRequest();
//初始化个人高级证书信息
PersonalSeniorCertificate personalSeniorCertificate = getPersonalSeniorCertificate();
request.setPersonalSeniorCertificate(personalSeniorCertificate);
//设置P10
request.setPkCS10("MIIBOTCB3QIBADB7MQ0wCwYDVQQDDARuYW1lMREwDwYDVQQLDAhCSkNBIFImRDENMAsGA1UECgwEQkpDQTEQMA4GA1UEBwwHLOWMl+S6rDELMAkGA1UECAwCYmoxCzAJBgNVBAYTAkNOMRwwGgYJKoZIhvcNAQkBFg1tYWlsQGJqY2EuY29tMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEIMVIdr0yuW4GpiXmHqpETGG/ETYe87WMKO/xuLo968y84GnKb99tWnQ44eG/AOJLTBTmVCYmjXHcJrREAqzPdKAAMAwGCCqBHM9VAYN1BQADSQAwRgIhAIS0ygb73cIZ8YqjXGeaf1K7nBxmEbs9YpIK1rTkRoaaAiEAx12lLcipB0FH4yLdw29xx8JyENAWVCIsFcrUTQgiIHE=");
request.setExtend("456extend");
request.setPassword("789pass");
request.setKeyId("test");
AgentInfo agentInfo = new AgentInfo();
agentInfo.setAgentEmail("11@qq.com");
agentInfo.setAgentName("测试个人发证");
agentInfo.setAgentPhone("15295586469");
agentInfo.setAgentId("362229188808224477");
agentInfo.setNote("a其它");
request.setAgentInfo(agentInfo);
//调用证书签发接口
PersonalIssueResponse personalIssueResponse = null;
try {
personalIssueResponse = personalCertSopApi.issue(request);
//后续业务处理
System.out.println("================================");
System.out.println("签发成功,响应内容:" + personalIssueResponse);
System.out.println("================================");
System.out.println("SDK请求ID:" + personalIssueResponse.getRequestId());
System.out.println("SDK响应消息:" + personalIssueResponse.getMsg());
System.out.println("SDK响应码:" + personalIssueResponse.getErrorCode());
System.out.println("================================");
if (null != personalIssueResponse.getData()) {
System.out.println("证书ID:" + personalIssueResponse.getData().getSerial());
System.out.println("加密证书:" + personalIssueResponse.getData().getEncryptionCert());
System.out.println("加密证书私钥:" + personalIssueResponse.getData().getEncryptionPrivateKey());
System.out.println("skf加密证书私钥:" + personalIssueResponse.getData().getSkfEnvelopedKeyBlob());
System.out.println("签名证书:" + personalIssueResponse.getData().getSignatureCert());
System.out.println("业务响应码:" + personalIssueResponse.getData().getIncorrect());
System.out.println("业务响应消息:" + personalIssueResponse.getData().getMessage());
System.out.println("介质信息:" + enterpriseIssueResponse.getData().getMedium());

}
} catch (ApiException e) {
e.printStackTrace();
}
}


/**
* 构造个人高级证书签发请求 在main方法里测试时该方法要加static关键字
*
* @return 个人高级证书
* @throws ParseException parseException
*/
private PersonalSeniorCertificate getPersonalSeniorCertificate() throws ParseException {
PersonalSeniorCertificate personalSeniorCertificate = new PersonalSeniorCertificate();
//设置个人证书定制信息
personalSeniorCertificate.setIdNumber("320125201809093418");
personalSeniorCertificate.setIdType(IdType.ID);
personalSeniorCertificate.setPhoneNumber("17311111111");
personalSeniorCertificate.setOwnerName("测试");
// 设置证书基本信息
personalSeniorCertificate.setCommonName("测试");
personalSeniorCertificate.setOrganization("测试");
personalSeniorCertificate.setOrganizationUnit("测试");
personalSeniorCertificate.setCountry("CN");
personalSeniorCertificate.setProvince("测试");
personalSeniorCertificate.setCity("测试");
personalSeniorCertificate.setDistrictCounty("测试");
personalSeniorCertificate.setEmail("zhugeliang@han.cn");
personalSeniorCertificate.setMedium("介质号");
personalSeniorCertificate.setAccountId("accountIdTest");
return personalSeniorCertificate;
}
}

三、响应参数

data 结果信息 类型 描述
msg String 业务描述
code String 业务返回码
signatureCert String 签名证书
encryptionCert String 加密证书
encryptionPrivateKey String 加密私钥
skfEnvelopedKeyBlob String skf加密私钥
serial String 证书序列号
medium String 介质号

四、成功示例

JSON示例

{
"code": 0,
"meg":"success",
"requestId": null,
"data": {
"serial":"2021020300508655",
"signatureCert":"MIICsz...",
"encryptionCert":"MIICsjCCA....",
"encryptionPrivateKey":"MIHtMAkGByqB...",
"skfEnvelopedKeyBlob":"AAQCAAEEAAC...",
"medium":"介质号",
"success":true
}
}

五、失败示例

JSON示例

{
"errorCode":30200302,
"msg":"appKey不存在",
"requestId":null,
"body":{
"code":30200302,
"message":"appKey不存在",
"requestId":null,
"data":null,
"success":false
}
}

六、返回码说明(incorrect)

返回码 描述
0 证书签发成功
其它 参考异常代码表

证书签发-企业证书

传入企业信息,进行证书的申请和签发。

一、请求说明

二、请求参数(请求方式为 post)

名称 类型 是否必须 描述
request EnterpriseIssueRequest 企业证书签发请求

EnterpriseIssueRequest 说明:

名称 类型 是否必须 描述
enterpriseSeniorCertificate EnterpriseSeniorCertificate 企业高级证书实体信息
pkCS10 String 用于制作证书的 pkCS10
extensions Map 扩展属性
agentInfo AgentInfo 经办人信息(非合约用户必传经办人手机号)
password String 交易密码
extend String 预留信息
keyId String keyId

EnterpriseSeniorCertificate 说明:

名称 类型 是否必须 描述
enterprise String 企业名称
department String 部门名称
idType IdType 证件类型
idNumber String 证件号,需要与证件类型匹配
phoneNumber String 联系号码
ownerName String 证书持有者姓名
commonName String 证书 CN 项,证书持有者名称
organization String 证书 O 项,证书所属组织
organizationUnit String 证书 OU 项,证书所属组织单元
country String 证书 C 项,国家,默认 CN
province String 证书 S 项,证书所属省
city String 证书 L 项,证书所属市
districtCounty String 证书所属区县
givenName String 名字,证书GIVENNAME项
email String 证书所属人邮箱
extraExtension List<Extension> 证书扩展项
medium String 介质信息
accountId String 交易账号

Extension 说明:

名称 类型 描述
oid String 扩展项oid值
value String 扩展项值
name String 扩展项名称

证件类型(IdType)说明:

名称 描述
ID 身份证
PASSPORT 护照
MILITARY_ID 军人身份证
BUSINESS_REGISTRATION_CERT 工商登记证
TAX_REGISTRATION_CERT 税务登记证
SHAREHOLDER_CODE_CERT 股东代码证
SOCIAL_SECURITY_CARD 社会保障卡
ARMED_POLICE 武装警察身份证件
HK_MACAU_PASSPORT 港澳居民往来内地通行证
TAIWAN_PASSPORT 台湾居民往来内地通行证
HOUSEHOLD_REGISTER 户口簿
TEMPORARY_ID 临时身份证
POLICE_CERT 警官证
PERMANENT_RESIDENCE_PERMIT 外国人永久居留证
GOVERNMENT_APPROVAL 政府批文
UNIFIED_SOCIAL_CERT 统一社会信用代码证
PRIVATE_NON_ENTERPRISE_CERT 民办非企业登记证书
CORPORATE_CERT 法人证书
OTHER 其他

经办人信息(AgentInfo) 说明:

名称 类型 是否必须 描述
agentName String 经办人姓名
agentId String 经办人身份证号
agentPhone String 经办人手机号码
agentEmail String 经办人邮箱
note String 经办人备注

代码实例:

public class EnterpriseCertSopApiTest {

/**
* 企业证书签发测试
*/
@Test
public void testIssue() throws Exception {
// 提供的服务地址map集合
HashMap<String, String> map = new HashMap<String, String>();
map.put("cip.api.gf.demo.smartcert.cn", "cn-beijing-1");
map.put("cip.api.gx.demo.smartcert.cn","cn-nanjing-1");
// 优先地域
String location = "cn-nanjing";
// 备用地域集合
List<String> reserveLocation = new ArrayList<String>();
reserveLocation.add("cn-beijing");
// 您的appKey
String appKey = "w8MuGC9C";
// 您的secretKey
String secretKey = "4wVznIMB";
// 构造接口实例
ApiClient apiClient = new DefaultApiClient(map, location, reserveLocation, appKey, secretKey);
EnterpriseCertSopApi enterpriseCertSopApi = new EnterpriseCertSopApiImpl(apiClient);
//构造企业高级证书签发请求
EnterpriseIssueRequest request = new EnterpriseIssueRequest();
//初始化企业高级证书信息
EnterpriseSeniorCertificate enterpriseSeniorCertificate = getEnterpriseSeniorCertificate();
request.setEnterpriseSeniorCertificate(enterpriseSeniorCertificate);
//设置P10
request.setPkCS10(p10);
request.setExtend("456extend");
request.setPassword("789pass");
AgentInfo agentInfo = new AgentInfo();
agentInfo.setAgentEmail("11@qq.com");
agentInfo.setAgentName("测试企业发证");
agentInfo.setAgentPhone("15295586469");
agentInfo.setAgentId("362229188808224477");
agentInfo.setNote("a其它");
request.setAgentInfo(agentInfo);
request.setKeyId("test");
//调用证书签发接口
EnterpriseIssueResponse enterpriseIssueResponse = null;
try {
enterpriseIssueResponse = enterpriseCertSopApi.issue(request);
//后续业务处理
System.out.println("================================");
System.out.println("响应内容:" + enterpriseIssueResponse);
System.out.println("================================");
System.out.println("SDK请求ID:" + enterpriseIssueResponse.getRequestId());
System.out.println("SDK响应消息:" + enterpriseIssueResponse.getMsg());
System.out.println("SDK响应码:" + enterpriseIssueResponse.getErrorCode());
System.out.println("================================");
if (null != enterpriseIssueResponse.getData()) {
System.out.println("证书ID:" + enterpriseIssueResponse.getData().getSerial());
System.out.println("加密证书:" + enterpriseIssueResponse.getData().getEncryptionCert());
System.out.println("加密证书私钥:" + enterpriseIssueResponse.getData().getEncryptionPrivateKey());
System.out.println("SKF加密证书私钥:" + enterpriseIssueResponse.getData().getSkfEnvelopedKeyBlob());
System.out.println("签名证书:" + enterpriseIssueResponse.getData().getSignatureCert());
System.out.println("业务响应码:" + enterpriseIssueResponse.getData().getIncorrect());
System.out.println("业务响应消息:" + enterpriseIssueResponse.getData().getMessage());
System.out.println("介质信息:" + enterpriseIssueResponse.getData().getMedium());

}
} catch (ApiException e) {
e.printStackTrace();
}
}

/**
* 生成企业证书信息 在main方法里测试时该方法要加static关键字
*
* @return 企业证书信息
* @throws ParseException parseException
*/
private EnterpriseSeniorCertificate getEnterpriseSeniorCertificate() throws ParseException{
EnterpriseSeniorCertificate enterpriseSeniorCertificate = new EnterpriseSeniorCertificate();
//设置企业证书定制信息
enterpriseSeniorCertificate.setIdNumber("25258545655");
enterpriseSeniorCertificate.setIdType(IdType.BUSINESS_REGISTRATION_CERT);
enterpriseSeniorCertificate.setPhoneNumber("17311111111");
enterpriseSeniorCertificate.setOwnerName("测试");
// 设置证书基本信息
enterpriseSeniorCertificate.setCommonName("测试");
enterpriseSeniorCertificate.setOrganization("测试");
enterpriseSeniorCertificate.setOrganizationUnit("测试");
enterpriseSeniorCertificate.setCountry("CN");
enterpriseSeniorCertificate.setProvince("测试");
enterpriseSeniorCertificate.setCity("测试");
enterpriseSeniorCertificate.setDistrictCounty("测试");
enterpriseSeniorCertificate.setEmail("yingzheng@qin.cn");
enterpriseSeniorCertificate.setMedium("介质号");
enterpriseSeniorCertificate.setAccountId("accountIdTest");
return enterpriseSeniorCertificate;
}

}

三、响应参数

data 结果信息 类型 描述
msg String 业务描述
code String 业务返回码
signatureCert String 签名证书
encryptionCert String 加密证书
encryptionPrivateKey String 加密私钥
skfEnvelopedKeyBlob String skf加密私钥
serial String 证书序列号
medium String 介质信息

四、成功示例

JSON示例

{
"code":0,
"message":"success",
"requestId":null,
"data": {
"serial":"2021020300508775",
"signatureCert":"MIICmjCC...",
"encryptionCert":"MIICmjCC...",
"encryptionPrivateKey":"MIHtMA...",
"skfEnvelopedKeyBlob":"AAQCAAEEA...",
"medium":"介质信息"
},
"success":true
}

五、失败示例

JSON示例

{
"errorCode":30200302,
"msg":"appKey不存在",
"requestId":null,
"body":{
"code":30200302,
"message":"appKey不存在",
"requestId":null,
"data":null,
"success":false
}
}

六、返回码说明(incorrect)

返回码 描述
0 证书签发成功
其它 参考异常代码表

证书重发

传入身份信息,进行证书的重发。

一、公共参数

二、请求参数(请求方式为 post)

名称 类型 是否必须 描述
request CertReIssueRequest 证书重发请求

CertReIssueRequest 说明:

名称 类型 是否必须 描述
pkCS10 String 用于制作证书的 pkCS10
extensions Map 扩展属性
serial String 原证书序列号
accountId String 交易账号
password String 交易密码
extend String 预留信息
p1signature String P1签名值(Base64格式)
keyId String keyId

Extension 说明:

名称 类型 描述
oid String 扩展项oid值
value String 扩展项值
name String 扩展项名称

代码实例:

public class PersonalCertSopApiTest {

/**
* 个人高级证书重发(重发逻辑--先去签发一个新的证书,签发成功后再根据传过去的证书序列号进行注销)
*/
@Test
public void testReIssue() throws Exception {
// 提供的服务地址map集合
HashMap<String, String> map = new HashMap<String, String>();
map.put("cip.api.gf.demo.smartcert.cn", "cn-beijing-1");
map.put("cip.api.gx.demo.smartcert.cn","cn-nanjing-1");
// 优先地域
String location = "cn-nanjing";
// 备用地域集合
List<String> reserveLocation = new ArrayList<String>();
reserveLocation.add("cn-beijing");
// 您的appKey
String appKey = "w8MuGC9C";
// 您的secretKey
String secretKey = "4wVznIMB";
// 构造接口实例
ApiClient apiClient = new DefaultApiClient(map, location, reserveLocation, appKey, secretKey);
CertSopApi certSopApi = new CertSopApiImpl(apiClient);

//构造证书重发请求
CertReIssueRequest request = new CertReIssueRequest();
//当中台开启身份验证时,参数必传,否则发证等接口会身份验证失败
request.setAccountId("23131231");
request.setPassword("sdadasasda");
request.setExtend("333");
request.setSerial("00E958DEBD243C68191C111B51");
//设置P10
request.setPkCS10("MIIBIjCBxwIBADBnMRIwEAYDVQQDDAnor7jokZvkuq4xDzANBgNVBAsMBuicgOaxiTERMA8GA1UECgwI5YiY5aSHQ0ExDzANBgNVBAgMBuilv+icgDEPMA0GA1UEBwwG5oiQ6YO9MQswCQYDVQQGEwJDTjBZMBMGByqGSM49AgEGCCqBHM9VAYItA0IABIUT+EXmwY/3CHmXV76+f5FznDrjEUZyJodlZdrbeJT9Lw9ChcSL+KqALJlEyM9C3A031qfzrEj2nxVv6lYDBwQwDAYIKoEcz1UBg3UFAANIADBFAiAGCsni7U6Fa/Uhq3YJw8HeprH50EAw2MbbBoeoZW/A0QIhAMoIb7acmuqaVXhA5YyWvn6P+VtUrE0KzOeTkTd1UCLx");
request.setKeyId("test");
//调用证书重发接口
CertReIssueResponse certReIssueResponse = null;
try {
certReIssueResponse = certSopApi.reIssue(request);
//后续业务处理
System.out.println("================================");
System.out.println("响应内容:" + certReIssueResponse);
System.out.println("================================");
System.out.println("SDK请求ID:" + certReIssueResponse.getRequestId());
System.out.println("SDK响应消息:" + certReIssueResponse.getMsg());
System.out.println("SDK响应码:" + certReIssueResponse.getErrorCode());
System.out.println("================================");
if (null != certReIssueResponse.getData()) {
System.out.println("证书ID:" + certReIssueResponse.getData().getSerial());
System.out.println("加密证书:" + certReIssueResponse.getData().getEncryptionCert());
System.out.println("加密证书私钥:" + certReIssueResponse.getData().getEncryptionPrivateKey());
System.out.println("签名证书:" + certReIssueResponse.getData().getSignatureCert());
System.out.println("业务响应码:" + certReIssueResponse.getData().getIncorrect());
System.out.println("业务响应消息:" + certReIssueResponse.getData().getMessage());
System.out.println("介质信息:" + certReIssueResponse.getData().getMedium());
}
} catch (ApiException e) {
e.printStackTrace();
}
}
}

三、响应参数

data 结果信息 类型 描述
msg String 业务描述
code String 业务返回码
signatureCert String 签名证书
encryptionCert String 加密证书
encryptionPrivateKey String 加密私钥
skfEnvelopedKeyBlob String skf加密私钥
serial String 证书序列号
medium String 介质号

四、成功示例

JSON示例

{
"code": 0,
"meg":"success",
"requestId": null,
"data": {
"serial":"2021020300508655",
"signatureCert":"MIICsz...",
"encryptionCert":"MIICsjCCA....",
"encryptionPrivateKey":"MIHtMAkGByqB...",
"skfEnvelopedKeyBlob":"AAQCAAEEAAC...",
"medium":"介质号",
"success":true
}
}

五、失败示例

JSON示例

{
"errorCode":30200302,
"msg":"appKey不存在",
"requestId":null,
"body":{
"code":30200302,
"message":"appKey不存在",
"requestId":null,
"data":null,
"success":false
}
}

六、返回码说明(incorrect)

返回码 描述
0 证书重发成功
其它 参考异常代码表

证书注销

输入证书标识,注销证书。

一、公共参数

二、请求参数

名称 类型 是否必须 描述
request RevokeRequest 证书注销请求

RevokeRequest 说明

名称 类型 是否必须 描述
serial String 证书序列号
accountId String 交易账号
password String 交易密码
extend String 预留信息
extensions Map 扩展属性
p1signature String P1签名值(Base64格式)

代码实例:

/**
* 证书注销测试
*/
@Test
public void testRevoke() {
// 提供的服务地址map集合
HashMap<String, String> map = new HashMap<String, String>();
map.put("cip.api.gf.demo.smartcert.cn", "cn-beijing-1");
map.put("cip.api.gx.demo.smartcert.cn","cn-nanjing-1");
// 优先地域
String location = "cn-nanjing";
// 备用地域集合
List<String> reserveLocation = new ArrayList<String>();
reserveLocation.add("cn-beijing");
// 您的appKey
String appKey = "w8MuGC9C";
// 您的secretKey
String secretKey = "4wVznIMB";
// 构造接口实例
ApiClient apiClient = new DefaultApiClient(map, location, reserveLocation, appKey, secretKey);
CertSopApi certSopApi = new CertSopApiImpl(apiClient);
//证书注销请求
RevokeRequest request = new RevokeRequest();
// 证书序列号
request.setSerial("2021020400509787");
try {
//调用注销服务
RevokeResponse revokeResponse = certSopApi.revoke(request);
//后续业务处理
System.out.println("================================");
System.out.println("响应内容:" + revokeResponse);
System.out.println("================================");
System.out.println("SDK请求ID:" + revokeResponse.getRequestId());
System.out.println("SDK响应消息:" + revokeResponse.getMsg());
System.out.println("SDK响应码:" + revokeResponse.getErrorCode());
System.out.println("================================");
if (null != revokeResponse.getData()) {
System.out.println("注销结果:" + revokeResponse.getData().getResult());
System.out.println("证书序列号:" + revokeResponse.getData().getSerial());
System.out.println("业务响应码:" + revokeResponse.getData().getIncorrect());
System.out.println("业务响应消息:" + revokeResponse.getData().getMessage());
System.out.println("介质信息:" + revokeResponse.getData().getMedium());
}
} catch (ApiException e) {
e.printStackTrace();
}
}

三、响应参数

业务响应名称 类型 描述
code String 结果响应码
msg String 注销说明
serial String 证书序列号
result Boolean 注销结果
medium String 介质信息

四、成功示例

JSON示例

{
"code":0,
"message":"success",
"requestId":null,"data":{
"serial":"2021020400509787",
"medium":"介质信息",
"result":true
},
"success":true
}

五、失败示例

JSON示例

{
"errorCode":30200302,
"msg":"appKey不存在",
"requestId":null,
"body":{
"code":30200302,
"message":"appKey不存在",
"requestId":null,
"data":null,
"success":false
}
}

六、返回码说明(incorrect)

返回码 描述
0 证书注销成功
其它 参考异常代码表

证书延期

输入证书标识和需要延期的天数,对该证书进行延期。

一、公共参数

二、请求参数

名称 类型 是否必须 描述
request PostponeRequest 证书延期请求

PostponeRequest 说明:

名称 类型 是否必须 描述
serial String 证书序列号
pkCS10 String 用于制作证书的 pkCS10
csrSignedData String 对P10进行签名后的pkCS7
userOldKey Boolean 是否使用原密钥对,默认为 True(此选项针对加密证书密钥对)
userOldKey Boolean 是否使用原密钥对,默认为 True(此选项针对加密证书密钥对)
accountId String 交易账号
password String 交易密码
extend String 预留信息
p1signature String P1签名值(Base64格式)
extensions Map 扩展属性
keyId String keyId

代码实例:

/**
* 证书延期测试
*/
@Test
public void testPostpone() {
// 提供的服务地址map集合
HashMap<String, String> map = new HashMap<String, String>();
map.put("cip.api.gf.demo.smartcert.cn", "cn-beijing-1");
map.put("cip.api.gx.demo.smartcert.cn","cn-nanjing-1");
// 优先地域
String location = "cn-nanjing";
// 备用地域集合
List<String> reserveLocation = new ArrayList<String>();
reserveLocation.add("cn-beijing");
// 您的appKey
String appKey = "w8MuGC9C";
// 您的secretKey
String secretKey = "4wVznIMB";
// 构造接口实例
ApiClient apiClient = new DefaultApiClient(map, location, reserveLocation, appKey, secretKey);
CertSopApi certSopApi = new CertSopApiImpl(apiClient);
// 证书延期请求
PostponeRequest request = new PostponeRequest();
// 证书序列号
request.setSerial("2021020400509875");
// 设置延期使用的制证P10,可以不设置,不设置默认使用原证书内容,不做密钥变动
// request.setPkCS10("pkcs10");
// 是否使用是否使用原密钥对,默认为true。如果设置false,则需要设置PcCS10属性。
// request.setUserOldKey(true);
request.setKeyId("test");
try {
//调用延期服务
PostponeResponse postponeResponse = certSopApi.postpone(request);
//后续业务处理
System.out.println("================================");
System.out.println("响应内容:" + postponeResponse);
System.out.println("================================");
System.out.println("SDK请求ID:" + postponeResponse.getRequestId());
System.out.println("SDK响应消息:" + postponeResponse.getMsg());
System.out.println("SDK响应码:" + postponeResponse.getErrorCode());
System.out.println("================================");
if (null != postponeResponse.getData()) {
System.out.println("证书序列号:" + postponeResponse.getData().getSerial());
System.out.println("加密证书:" + postponeResponse.getData().getEncryptionCert());
System.out.println("加密证书私钥:" + postponeResponse.getData().getEncryptionPrivateKey());
System.out.println("签名证书:" + postponeResponse.getData().getSignatureCert());
System.out.println("业务响应码:" + postponeResponse.getData().getIncorrect());
System.out.println("业务响应消息:" + postponeResponse.getData().getMessage());
System.out.println("介质信息:" + enterpriseIssueResponse.getData().getMedium());

}
} catch (ApiException e) {
e.printStackTrace();
}
}

三、响应参数

data 结果信息 类型 描述
signatureCert String 签名证书
encryptionCert String 加密证书
encryptionPrivateKey String 加密私钥
skfEnvelopedKeyBlob String skf加密私钥
serial String 证书序列号
medium String 介质信息
msg String 业务响应描述
code String 业务返回码

四、成功示例

JSON示例

{
"code":0,
"message":"success",
"requestId":null,
"data": {
"serial":"2021020300508775",
"signatureCert":"MIICmjCC...",
"encryptionCert":"MIICmjCC...",
"encryptionPrivateKey":"MIHtMA...",
"medium":"介质信息",
"skfEnvelopedKeyBlob":"AAQCAAEEA..."
},
"success":true
}

五、失败示例

JSON示例

{
"errorCode":30200302,
"msg":"appKey不存在",
"requestId":null,
"body":{
"code":30200302,
"message":"appKey不存在",
"requestId":null,
"data":null,
"success":false
}
}

六、返回码说明(incorrect)

返回码 描述
0 延期成功
其它 参考异常代码表

根据serial查询证书

传入证书serial,精确查询证书。

一、公共参数

二、请求参数(请求方式为 GET)

名称 类型 是否必须 描述
request CertQueryBySerialRequest 根据证书serial查询证书请求

CertQueryBySerialRequest 说明:

名称 类型 是否必须 描述
serial String 待查询证书序列号

代码实例:

/***
* 查询证书测试
*/
@Test
public void getBySerial() {
// 提供的服务地址map集合
HashMap<String, String> map = new HashMap<String, String>();
map.put("cip.api.gf.demo.smartcert.cn", "cn-beijing-1");
map.put("cip.api.gx.demo.smartcert.cn","cn-nanjing-1");
// 优先地域
String location = "cn-nanjing";
// 备用地域集合
List<String> reserveLocation = new ArrayList<String>();
reserveLocation.add("cn-beijing");
// 您的appKey
String appKey = "w8MuGC9C";
// 您的secretKey
String secretKey = "4wVznIMB";
// 构造接口实例
ApiClient apiClient = new DefaultApiClient(map, location, reserveLocation, appKey, secretKey);
CertSopApi certSopApi = new CertSopApiImpl(apiClient);
// 证书查询请求
CertQueryBySerialRequest request = new CertQueryBySerialRequest();
request.setSerial("2021020400509847");
try {
//调用查询业务
CertQueryBySerialResponse certQueryBySerialResponse = certSopApi.queryBySerial(request);
//后续业务处理
System.out.println("================================");
System.out.println("响应内容:" + certQueryBySerialResponse);
System.out.println("================================");
System.out.println("SDK请求ID:" + certQueryBySerialResponse.getRequestId());
System.out.println("SDK响应消息:" + certQueryBySerialResponse.getMsg());
System.out.println("SDK响应码:" + certQueryBySerialResponse.getErrorCode());
System.out.println("================================");
if (null != certQueryBySerialResponse.getData()) {
System.out.println("业务响应码:" + certQueryBySerialResponse.getData().getIncorrect());
System.out.println("业务响应消息:" + certQueryBySerialResponse.getData().getMessage());
System.out.println("证书列表:" + certQueryBySerialResponse.getData().getCertificate());

}

} catch (ApiException e) {
e.printStackTrace();
}
}

三、响应参数

data 结果信息 类型 描述
certJson String 证书对象json 格式

四、成功示例

JSON示例

{
"code":0,
"message":"success",
"requestId":"uhoRcXOe1A",
"data":{
"incorrect":"0",
"certJson":"{"certSerial":"2021031100571857","certificateType":"ENTERPRISE_SENIOR","city":"咸阳1","accountId":"accountId123","commonName":"嬴政","country":"","districtCounty":"咸阳2","encCertificate":"MIICmTCCAj+gAwIBAgIIICEDEQBXGFgwCgYIKoEcz1UBg3UwdjEcMBoGA1UEAwwTU21hcnRDQV9UZXN0X1NNMl9DQTEVMBMGA1UECwwMU21hcnRDQV9UZXN0MRAwDgYDVQQKDAdTbWFydENBMQ8wDQYDVQQHDAbljZfkuqwxDzANBgNVBAgMBuaxn+iLjzELMAkGA1UEBhMCQ04wHhcNMjEwMzExMDUxNjQyWhcNMjIwMzExMDUxNjQyWjCBtDEwMC4GA1UELQwnMzgzNDdhODgxYTA1NDA0YmE2Y2MwNTBjZmFlNTZlNDEyMDIxMDNEMR8wHQYJKoZIhvcNAQkBDBB5aW5nemhlbmdAcWluLmNuMQowCAYDVQQGEwHmMQ8wDQYDVQQIDAblkrjpmLMxEDAOBgNVBAcMB+WSuOmYszExDTALBgNVBAoMBEJKQ0ExDTALBgNVBAsMBETooagxEjAQBgNVBAMMCeWstOaUv0AzNDBZMBMGByqGSM49AgEGCCqBHM9VAYItA0IABK88LkCKCim4utjvOpxO6sbRS+XAwshVpEC/JEuYXkI51kpj0i3uJ62Ft6sKGqxv3r4nt053+Op4j7OzgbkK0uejeDB2MAsGA1UdDwQEAwIDODAMBgNVHRMEBTADAQH/MB0GA1UdDgQWBBTpota15Llh3n5bXqMkFB+baUVQjjAfBgNVHSMEGDAWgBRc87oljMJlDOxn777djWunXq/jrDAZBggqgRzQFAQBAwQNEwsyNTI1ODU0NTY1NTAKBggqgRzPVQGDdQNIADBFAiEAh1iJgubeuMoa87JGOJb3XYWyeC2o0KCA0CxOdc2gL9QCICGGpIa4iTqvKdhVNvIbbBiz9LENJ2ZBKlNx63K3ZdFz","encryptionPrivateKey":"MIHtMAkGByqBHM9VAWgweQIhAMPGvfd1rSEhM9oJ3FPQeK6+gCeiaA3dvZw2r/2DfLmEAiAdBHvAtFdRePKE02R67Y4gaHnrpbU2XPmkY4eGr2mSFwQg217NOnNAnKp/4ZuzV4byr8R+E7+s/Sfgc9MhFHiRykYEEA/H5COLCI3uoLf3JU1NzlkDQgAErzwuQIoKKbi62O86nE7qxtFL5cDCyFWkQL8kS5heQjnWSmPSLe4nrYW3qwoarG/evie3Tnf46niPs7OBuQrS5wMhAEZYlED1bqwArTg/CKZ7Q5ELuBaZtubY5Gd9G+iwr8W+","fingerprint":"f286ae0bbfe0b5ac60a1a953234da9665251ffc6","id":"2bf2b7e495694222ad444cb38758811c202103","idNumber":"25258545655","idType":"BUSINESS_REGISTRATION_CERT","issuer":"CN=SmartCA_Test_SM2_CA,OU=SmartCA_Test,O=SmartCA,L=南京,ST=江苏,C=CN","medium":"介质号","notAfter":1646975802000,"notBefore":1615439802000,"operateTime":1615439807183,"organization":"嬴政1","organizationUnit":"皇帝","province":"咸阳","raCode":"fbac26e3cea84c4b9198a46b1cffe992","raDesc":"智慧RA企业","sigCertificate":"MIICmTCCAj+gAwIBAgIIICEDEQBXGFcwCgYIKoEcz1UBg3UwdjEcMBoGA1UEAwwTU21hcnRDQV9UZXN0X1NNMl9DQTEVMBMGA1UECwwMU21hcnRDQV9UZXN0MRAwDgYDVQQKDAdTbWFydENBMQ8wDQYDVQQHDAbljZfkuqwxDzANBgNVBAgMBuaxn+iLjzELMAkGA1UEBhMCQ04wHhcNMjEwMzExMDUxNjQyWhcNMjIwMzExMDUxNjQyWjCBtDEwMC4GA1UELQwnMzgzNDdhODgxYTA1NDA0YmE2Y2MwNTBjZmFlNTZlNDEyMDIxMDNEMR8wHQYJKoZIhvcNAQkBDBB5aW5nemhlbmdAcWluLmNuMQowCAYDVQQGEwHmMQ8wDQYDVQQIDAblkrjpmLMxEDAOBgNVBAcMB+WSuOmYszExDTALBgNVBAoMBEJKQ0ExDTALBgNVBAsMBETooagxEjAQBgNVBAMMCeWstOaUv0AzNDBZMBMGByqGSM49AgEGCCqBHM9VAYItA0IABIaUMbAwU5WQGRS0Wgy0McnrskNurF0NgEBjCvgxbvWXPznQEmWT+jnv1dn1m6bdDEUlXFsMxPomrNPSf2xWwCajeDB2MAsGA1UdDwQEAwIGwDAMBgNVHRMEBTADAQH/MB0GA1UdDgQWBBSP8WU10ScXPpxlb+of/moHZg+OtzAfBgNVHSMEGDAWgBRc87oljMJlDOxn777djWunXq/jrDAZBggqgRzQFAQBAwQNEwsyNTI1ODU0NTY1NTAKBggqgRzPVQGDdQNIADBFAiEAtOMCk6TLpDopGjLjdpEUVHcer/QrAPCvUr2fwjveKrACIDq72Bo5SXUNRnRFh+6bE1GNYoblPmkjwAqNU3LOlj2A","status":"2000","subject":"CN=嬴政,OU=皇帝,O=嬴政1,L=咸阳1,ST=咸阳,C=秦","subjectRa":"UniqueIdentifier=38347a881a05404ba6cc050cfae56e41202103D,E=yingzheng@qin.cn,C=æ,ST=咸阳,L=咸阳1,O=BJCA,OU=D表,CN=嬴政@34","version":"2"}"
},
"success":true
}

五、失败示例

JSON示例

{
"errorCode":30200302,
"msg":"appKey不存在",
"requestId":null,
"body":{
"code":30200302,
"message":"appKey不存在",
"requestId":null,
"data":null,
"success":false
}
}

六、返回码说明(incorrect)

返回码 描述
0 证书查询成功
其它 参考异常代码表

查询证书状态

传入证书serial,查询证书状态。

一、公共参数

二、请求参数(请求方式为 GET)

名称 类型 是否必须 描述
request CertCheckBySerialRequest 根据证书serial查询证书状态

CertCheckBySerialResponse 说明:

名称 类型 是否必须 描述
serial String 待查询证书序列号

代码实例:

/***
* 校验证书状态
*/
@Test
public void checkBySerial() {
// 提供的服务地址map集合
HashMap<String, String> map = new HashMap<String, String>();
map.put("cip.api.gf.demo.smartcert.cn", "cn-beijing-1");
map.put("cip.api.gx.demo.smartcert.cn","cn-nanjing-1");
// 优先地域
String location = "cn-nanjing";
// 备用地域集合
List<String> reserveLocation = new ArrayList<String>();
reserveLocation.add("cn-beijing");
// 您的appKey
String appKey = "w8MuGC9C";
// 您的secretKey
String secretKey = "4wVznIMB";
// 构造接口实例
ApiClient apiClient = new DefaultApiClient(map, location, reserveLocation, appKey, secretKey);
CertSopApi certSopApi = new CertSopApiImpl(apiClient);
// 证书查询请求
CertCheckBySerialRequest request = new CertCheckBySerialRequest();
request.setSerial("6d1fd8a15ff885df553340eea1e26241b165ee44");
try {
//调用查询业务
CertCheckBySerialResponse certQueryBySerialResponse = certSopApi.checkBySerial(request);
//后续业务处理
System.out.println("================================");
System.out.println("响应内容:" + certQueryBySerialResponse);
System.out.println("================================");
System.out.println("SDK请求ID:" + certQueryBySerialResponse.getRequestId());
System.out.println("SDK响应消息:" + certQueryBySerialResponse.getMsg());
System.out.println("SDK响应码:" + certQueryBySerialResponse.getErrorCode());
System.out.println("================================");
if (null != certQueryBySerialResponse.getData()) {
System.out.println("业务响应码:" + certQueryBySerialResponse.getData().getIncorrect());
System.out.println("业务响应消息:" + certQueryBySerialResponse.getData().getMessage());
System.out.println("证书状态:" + certQueryBySerialResponse.getData().getResult());
}
} catch (ApiException e) {
e.printStackTrace();
}
}

三、响应参数

data 结果信息 类型 描述
result String 1 签发状态 0 注销状态 2 证书已过期 3 即将过期

四、成功示例

JSON示例

{
"code":0,
"message":"success",
"requestId":"vwRLJwqvon",
"data":{
"incorrect":"0",
"result":"0"
},
"success":true
}

五、失败示例

JSON示例

{
"code":30106,
"message":"证书不存在!",
"requestId":"HtKvGF6k7E",
"data":null,
"success":false
}

六、返回码说明(incorrect)

返回码 描述
0 证书查询成功
其它 参考异常代码表

查询时间戳查询keyid

传入时间戳timestamp,查询证书状态。

一、公共参数

二、请求参数(请求方式为 GET)

名称 类型 是否必须 描述
request CertKeyByTimeStampRequest 根据时间戳查询证书keyid

CertCheckBySerialResponse 说明:

名称 类型 是否必须 描述
timeStamp String 时间戳

代码实例:

 /***
* 根据时间戳查询证书keyid
*/
@Test
public void certKeyTest() throws ApiException {
// 证书查询请求
CertKeyByTimeStampRequest certKeyByTimeStampRequest = new CertKeyByTimeStampRequest();
certKeyByTimeStampRequest.setTimeStamp(null);
//调用查询业务
CertKeyByTimeStampResponse certKeyByTimeStampResponse = certSopApi.certKeyByTimeStamp(certKeyByTimeStampRequest);
//后续业务处理
System.out.println("================================");
System.out.println("调用成功,响应内容:" + certKeyByTimeStampResponse);
System.out.println("================================");
System.out.println("调用成功,SDK请求ID:" + certKeyByTimeStampResponse.getRequestId());
System.out.println("调用成功,SDK响应消息:" + certKeyByTimeStampResponse.getMsg());
System.out.println("调用成功,SDK响应码:" + certKeyByTimeStampResponse.getErrorCode());
System.out.println("================================");
if (null != certKeyByTimeStampResponse.getData()) {
System.out.println("状态查询成功,业务响应数据:" + certKeyByTimeStampResponse.getData().getCertKeyDtos());
}
}

三、响应参数

data 结果信息 类型 描述
certKeyDtos List 证书keyid列表

CertKeyDto 说明:

名称 类型 描述
keyId String 协签keyid
certSerial String 证书序列号
methodName String 方法名
timestamp String 时间戳
certStatus String 证书状态 2000-已签发 4000-已注销

四、成功示例

JSON示例

{
"code":0,
"message":"success",
"requestId":"KMEUW2kDrn",
"data":{
"certKeyDtos":[
{
"keyId":"123",
"certSerial":"3300000007434894",
"methodName":"证书签发",
"timestamp":"1619405640802"
}
]
},
"success":true
}

五、失败示例

JSON示例

{
"errorCode":30200302,
"msg":"appKey不存在",
"requestId":null,
"body":{
"code":30200302,
"message":"appKey不存在",
"requestId":null,
"data":null,
"success":false
}
}

六、返回码说明(incorrect)

返回码 描述
0 证书查询成功
其它 参考异常代码表

根据交易账号查询证书列表

传入交易账号,查询该交易账号所签发未注销证书列表。

一、公共参数

二、请求参数(请求方式为 GET)

名称 类型 是否必须 描述
request QueryByAccountIdRequest 根据客户编码查询证书列表

QueryByAccountIdRequest 说明:

名称 类型 是否必须 描述
accountId String 交易账号

代码实例:

/***
* 查询证书统计
*/
@Test
public void queryByAccountId() {
// 提供的服务地址map集合
HashMap<String, String> map = new HashMap<String, String>();
map.put("cip.api.gf.demo.smartcert.cn", "cn-beijing-1");
map.put("cip.api.gx.demo.smartcert.cn","cn-nanjing-1");
// 优先地域
String location = "cn-nanjing";
// 备用地域集合
List<String> reserveLocation = new ArrayList<String>();
reserveLocation.add("cn-beijing");
// 您的appKey
String appKey = "w8MuGC9C";
// 您的secretKey
String secretKey = "4wVznIMB";
// 构造接口实例
ApiClient apiClient = new DefaultApiClient(map, location, reserveLocation, appKey, secretKey);
CertSopApi certSopApi = new CertSopApiImpl(apiClient);
// 证书统计查询请求
QueryByAccountIdRequest request = new QueryByAccountIdRequest();
request.setAccountId("accountIdTest");
try {
//调用查询业务
QueryByAccountIdResponse certQueryBySerialResponse = certSopApi.countByClientId(request);
//后续业务处理
System.out.println("================================");
System.out.println("响应内容:" + certQueryBySerialResponse);
System.out.println("================================");
System.out.println("SDK请求ID:" + certQueryBySerialResponse.getRequestId());
System.out.println("SDK响应消息:" + certQueryBySerialResponse.getMsg());
System.out.println("SDK响应码:" + certQueryBySerialResponse.getErrorCode());
System.out.println("================================");
if (null != certQueryBySerialResponse.getData()) {
System.out.println("业务响应码:" + certQueryBySerialResponse.getData().getIncorrect());
System.out.println("业务响应消息:" + certQueryBySerialResponse.getData().getMessage());
System.out.println("证书列表:" + certQueryBySerialResponse.getData().getSimpleCertList());
}
} catch (ApiException e) {
e.printStackTrace();
}
}

三、响应参数

data 结果信息 类型 描述
simpleCertList List<SimpleCert> 证书列表

SimpleCert 说明:

名称 类型 描述
certSerial String 证书序列号
notBefore String 证书起始有效期
notAfter String 证书截止有效期
medium String 证书介质信息

四、成功示例

JSON示例

{
"code":0,
"message":"success",
"requestId":"4MvyVwKzaV",
"data":{
"incorrect":"0",
"simpleCertList":[
{
"certSerial":"00b13af423884a05106bc9ae0b",
"notBefore":"2021-03-05",
"notAfter":"2022-03-05",
"medium":"IOS"
},
{
"certSerial":"171422bd606922fc534ce9c7772f08ff0bf09217",
"notBefore":"2021-03-12",
"notAfter":"2022-03-12",
"medium":null
}
]
},
"success":true
}

五、失败示例

JSON示例

{
"errorCode":30200302,
"msg":"appKey不存在",
"requestId":null,
"body":{
"code":30200302,
"message":"appKey不存在",
"requestId":null,
"data":null,
"success":false
}
}

六、返回码说明(incorrect)

返回码 描述
0 证书查询成功
其它 参考异常代码表

查询增量CRL

查询注销证书信息列表。

一、公共参数

二、请求参数(请求方式为 GET)

名称 类型 是否必须 描述
request CertCrlRequest 数据查询请求

CertCrlRequest 说明:

名称 类型 是否必须 描述
startTimestamp Long 起始时间戳 查询起启时间 默认 2021-1-1 00:00:00
count Integer 限制最大条数 默认 100

代码实例:

/***
* 查询增量crl
*/
@Test
public void getCrlIncrement() {
// 提供的服务地址map集合
HashMap<String, String> map = new HashMap<String, String>();
map.put("cip.api.gf.demo.smartcert.cn", "cn-beijing-1");
map.put("cip.api.gx.demo.smartcert.cn","cn-nanjing-1");
// 优先地域
String location = "cn-nanjing";
// 备用地域集合
List<String> reserveLocation = new ArrayList<String>();
reserveLocation.add("cn-beijing");
// 您的appKey
String appKey = "w8MuGC9C";
// 您的secretKey
String secretKey = "4wVznIMB";
// 构造接口实例
ApiClient apiClient = new DefaultApiClient(map, location, reserveLocation, appKey, secretKey);
CertCrlApi certSopApi = new CertCrlApiImpl(apiClient);
// 证书增量crl查询请求
CertCrlRequest request = new CertCrlRequest();
//起始时间 非必传
request.setStartTimestamp(1619343065199L);
// 数据量 非必传
request.setCount(500);
try {

CertCrlResponse response = certSopApi.getCrlIncrement(request);
//后续业务处理
System.out.println("================================");
System.out.println("响应内容:" + response);
System.out.println("================================");
System.out.println("SDK请求ID:" + response.getRequestId());
System.out.println("SDK响应消息:" + response.getMsg());
System.out.println("SDK响应码:" + response.getErrorCode());
System.out.println("================================");
if (null != response.getData()) {
System.out.println("crl数据列表:" + response.getData().getCertCrlList());
System.out.println("请求服务器时间戳:" + response.getData().getTimestamp());
}
} catch (ApiException e) {
e.printStackTrace();
}
}

三、响应参数

data 结果信息 类型 描述
certCrlList List<CrlDto> 证书列表
timestamp Long 服务器时间戳

CrlDto 说明:

名称 类型 描述
certSerial String 证书序列号
certDn String 证书主题项
timestamp Long 注销时间戳
notAfter Long 证书截止有效期
raType String ra类型 PUHUA 普华RA; UNI 先安UNI; SMART 智慧; TWCX 天威诚信;LCA 本地ca;CFCA CFCA
id String 唯一标识

四、成功示例

JSON示例

{
"code":0,
"message":"success",
"requestId":"KMEUW2kDrn",
"data":{
"certCrlList":[
{
"id":"d0fad423ee3e49f5a3d37ad22be6edb2",
"serial":"3300000007434894",
"certDn":"C=CN,ST=蜀地1,L=成都1,CN=刘禅12231619405625549",
"timestamp":1619405640802
}
]
},
"success":true
}

五、失败示例

JSON示例

{
"errorCode":30200302,
"msg":"appKey不存在",
"requestId":null,
"body":{
"code":30200302,
"message":"appKey不存在",
"requestId":null,
"data":null,
"success":false
}
}

六、返回码说明(incorrect)

返回码 描述
0 查询成功
其它 参考异常代码表

下载全量CRL文件

下载全量的CRL证书文件。

一、公共参数

二、请求参数(请求方式为 GET)

名称 类型 是否必须 描述
request CrlAllFileRequest 下载全量CRL请求

代码实例:

/***
* 查询增量crl
*/
@Test
public void getCrlIncrement() {
// 提供的服务地址map集合
HashMap<String, String> map = new HashMap<String, String>();
map.put("cip.api.gf.demo.smartcert.cn", "cn-beijing-1");
map.put("cip.api.gx.demo.smartcert.cn","cn-nanjing-1");
// 优先地域
String location = "cn-nanjing";
// 备用地域集合
List<String> reserveLocation = new ArrayList<String>();
reserveLocation.add("cn-beijing");
// 您的appKey
String appKey = "w8MuGC9C";
// 您的secretKey
String secretKey = "4wVznIMB";
// 构造接口实例
ApiClient apiClient = new DefaultApiClient(map, location, reserveLocation, appKey, secretKey);
CertCrlApi certSopApi = new CertCrlApiImpl(apiClient);
// 下载全量CRL请求
CrlAllFileRequest request = new CrlAllFileRequest();
try {

CrlAllFileResponse response = certSopApi.getCrlAllFile(request);
//后续业务处理
System.out.println("================================");
System.out.println("响应内容:" + response);
System.out.println("================================");
System.out.println("SDK请求ID:" + response.getRequestId());
System.out.println("SDK响应消息:" + response.getMsg());
System.out.println("SDK响应码:" + response.getErrorCode());
System.out.println("================================");
if (null != response.getData()) {
System.out.println("crl文件Hex字符串:" + response.getData().getCrlFileHexStr());
// 文件下载路径
File file = new File("d://cip-crl.crl");
FileUtils.writeByteArrayToFile(file, response.getData().getCrlFile());
}
} catch (ApiException | IOException e) {
e.printStackTrace();
}
}

三、响应参数

data 结果信息 类型 描述
crlFileHexStr String crl文件-Hex字符串
crlFile byte[] crl文件-byte数组

四、成功示例

JSON示例

{
"code":0,
"message":"success",
"requestId":"KMEUW2kDrn",
"data":{
"crlFileHexStr":"xxxxxxxxx"
},
"success":true
}

五、失败示例

JSON示例

{
"errorCode":30200302,
"msg":"appKey不存在",
"requestId":null,
"body":{
"code":30200302,
"message":"appKey不存在",
"requestId":null,
"data":null,
"success":false
}
}

六、返回码说明(incorrect)

返回码 描述
0 查询成功
其它 参考异常代码表

服务器证书签发

服务器证书签发。

一、公共参数

二、请求参数(请求方式为 GET)

名称 类型 是否必须 描述
request ApplyServerCertRequest 服务器证书签发请求

ApplyServerCertRequest 说明:

名称 类型 是否必须 描述
pkCS10 String Pkcs10
commonName String 证书名
hours Integer 证书有效时长(小时)
extend Map 扩展项

代码实例:


/**
* 服务器证书签发测试
*/
@Test
public void testServerCertIssue() throws Exception {
// 提供的服务地址map集合
HashMap<String, String> map = new HashMap<String, String>();
map.put("cip.api.gf.demo.smartcert.cn", "cn-beijing-1");
map.put("cip.api.gx.demo.smartcert.cn","cn-nanjing-1");
// 优先地域
String location = "cn-nanjing";
// 备用地域集合
List<String> reserveLocation = new ArrayList<String>();
reserveLocation.add("cn-beijing");
// 您的appKey
String appKey = "w8MuGC9C";
// 您的secretKey
String secretKey = "4wVznIMB";
// 构造接口实例
ApiClient apiClient = new DefaultApiClient(map, location, reserveLocation, appKey, secretKey);
CertSopApi sopApi = new CertSopApiImpl(apiClient);

//证书签发请求
ServerCertIssueRequest request = new ServerCertIssueRequest();
//证书名称
request.setCommonName("测试");
//证书有效期时长 小时
request.setHours(3);
//设置P10
request.setPkCS10("MIIBKzCB0QIBADBxMRQwEgYDVQQDDAvlkLTkvJ/kvJ93dzESMBAGA1UECwwJ5aO56K+B6YCaMRAwDgYDVQQKDAdTbWFydENBMRIwEAYDVQQHDAnljZfkuqzluIIxEjAQBgNVBAgMCeaxn+iLj+ecgTELMAkGA1UEBhMCQ04wWTATBgcqhkjOPQIBBggqgRzPVQGCLQNCAAT7DqQKwRpAFITWN7+h5OwnhR5SwVH7XcfJuZGKGJs/lMrgH3l2TkwoM82yxBNliGBoaW4YZoTpiQCnL3SWQD6qMAwGCCqBHM9VAYN1BQADRwAwRAIgP5hKJc7PITjPKWVfO1ZkEmDs2w2tqRus7zFozJmfHgcCIEFTSNdmr8ycPXLvreY6xxXYDkHJfL+yGitmRrnlFKVu");

//证书使用者可选名称 非必要
Map<String, String> certMap = new HashMap<String, String>();
// 非必传
List<GeneralNameSimple> list = new ArrayList<GeneralNameSimple>();
GeneralNameSimple generalNameSimple = new GeneralNameSimple("www.baidu.com",2);
GeneralNameSimple generalNameSimple1 = new GeneralNameSimple("www.baidu2.com",2);
GeneralNameSimple generalNameSimple2 = new GeneralNameSimple("192.168.10.1",7);
list.add(generalNameSimple);
list.add(generalNameSimple1);
list.add(generalNameSimple2);

certMap.put("generalName", JSONArray.toJSONString(list));
request.setExtend(map);

ServerCertIssueResponse response = null;
try {
response = sopApi.issueServerCert(request);

//后续业务处理
System.out.println("================================");
System.out.println("签发成功,响应内容:" + response);
System.out.println("================================");
System.out.println("SDK请求ID:" + response.getRequestId());
System.out.println("SDK响应消息:" + response.getMsg());
System.out.println("SDK响应码:" + response.getErrorCode());
System.out.println("================================");
if (null != response.getData()) {
System.out.println("证书序列号:" + response.getData().getSerial());
System.out.println("加密证书:" + response.getData().getEncryptionCert());
System.out.println("加密证书私钥:" + response.getData().getEncryptionPrivateKey());
System.out.println("签名证书:" + response.getData().getSignatureCert());
System.out.println("证书有效时长(小时):" + response.getData().getHours());
}
} catch (ApiException e) {
e.printStackTrace();
}
}

三、响应参数

data 结果信息 类型 描述
signatureCert String 签名证书
encryptionCert String 加密证书
encryptionPrivateKey String 加密私钥
serial String 证书序列号
hours Integer 证书有效时长(小时)

四、成功示例

JSON示例

{
"errorCode": 0,
"msg":"success",
"requestId": null,
"data": {
"serial":"2021020300508655",
"signatureCert":"MIICsz...",
"encryptionCert":"MIICsjCCA....",
"encryptionPrivateKey":"MIHtMAkGByqB...",
"hours":1
}
}

五、失败示例

JSON示例

{
"errorCode":30200302,
"msg":"appKey不存在",
"requestId":null,
"body":{
"code":30200302,
"message":"appKey不存在",
"requestId":null,
"data":null,
"success":false
}
}

六、返回码说明(incorrect)

返回码 描述
0 签发成功
其它 参考异常代码表