V2.0 Revoke Certificate


撤销设备绑定的证书。

该 API 支持在 EnOS 2.1.0 及以上环境中使用。

操作权限


使用此 API 前,确保服务账号已被授予包含下列服务和操作权限的策略。有关授权服务账号的更多信息,参见 管理服务账号


需授权的服务 所需操作权限
证书 Revoke

前提条件

  • 该设备存在
  • 该证书与该设备绑定
  • 该证书属于有效状态

请求格式

POST https://{apigw-address}/connect-service/v2.0/certificates?action=revoke

请求参数 (URI)

注解

以下非必需字段中,必须提供 assetIdproductKey + deviceKey 的组合,用于指定设备。

名称 位置(Path/Query) 必需/可选 数据类型 描述
orgId Query 必需 String 资产所属的组织 ID。如何获取 orgId 信息>>
assetId Query 可选(见上述注解) String 资产 ID。如何获取 assetId 信息>>
productKey Query 可选(见上述注解) String 设备的 product key,需与 deviceKey 一起使用。
deviceKey Query 可选(见上述注解) String 设备的 device key,需与 productKey 一起使用。

请求参数(Body)

名称 必需/可选 数据类型 描述
certSn 必需 Integer 需要撤销的证书序列号。这是申请证书时返回的 certSN 号,该号也能使用 List Certificate 接口获取。
reason 可选 Integer 撤销证书的原因。包括下列选项: + 0: UNSPECIFIED.未确定证书为何被吊销。 + 1: KEY_COMPROMISE.已知或怀疑证书使用者的私钥已被破坏。 + 3: AFFILIATION_CHANGED. 主体的名称或其他信息已更改。 + 4: SUPERSEDED:证书已被取代. 比如证书更新请求后原证书撤销。 + 5: CESSATION_OF_OPERATION. 不再需要该证书。 + 6: CERTIFICATE_HOLD. 证书已被搁置、冻结等。 + 9: PRIVILEGE_WITHDRAWN. 授予证书主体的授权已被撤消,即认为CA已经无效,没有权限授权证书,该证书已经不可信。

错误码

代码 类型 描述 解决方法
99400 invalid argument: Device identifier is invalid 设备标识符无效。 在请求中声明 assetIdproductKey + deviceKey 以指定设备。
99400 Invalid Argument certSn:certSn is missing 缺少 certSn 参数。 在请求中传入正确的 certSn 参数。
99400 Call ca error!: Certificate service err info:, code: (code), message: (message content), detail message: (detailed message content) 调用EnOS证书服务参数异常。 详细错误信息原因由message或 detail message给出。
99400 Invalid cert request!message: (message content), detail message: (detailed message content) 无效证书请求。 详细错误信息原因由message或 detail message给出。
99400 Query cert is failed!message: (message content), detail message: (detailed message content) 查询证书失败。 详细错误信息原因由message或 detail message给出。
99400 When calling Certificate Services, the call parameters are invalid.message: (message content), detail message: (detailed message content) 当调用证书服务时,调用参数无效。 详细错误信息原因由message或 detail message给出。
99400 Serial number of the certificate to be updated is required. 待更新证书的序列号是必需字段。 在请求中声明 certSn 参数。
99400 Serial number of the new certificate is invalid (less than 0). 传入的证书序列号无效(小于0)。 确保请求中声明的 certSn 参数有效。
99400 The certificate list bound to the device does not have the certificate,or the certificate is bound to other devices. 原证书未与设备绑定或绑定另一个设备。 确保证书有效。
11404 Device cannot be found 设备未找到。 确认该设备确实存在。
99500 Internal error of certificate service 设备连接与管理证书服务内部错误。 联系管理员。
99500 Internal error of product service. 设备连接与管理产品服务内部错误。 联系管理员。
99500 Internal error of IoT hub service 设备连接与管理内部服务错误。 联系管理员。

示例

请求示例

url: https://{apigw-address}/connect-service/v2.0/certificates?action=revoke&assetId=yourDeviceAssetId&orgId=yourOrgId
method: POST
requestBody:
{
    "reason":0,
    "certSn":52739
}

响应示例

{
    "code":0,
    "msg":"OK",
    "requestId":"e3391ff8-19ba-4809-b944-c1b29f468af9",
    "data":null
}

SDK 示例


你可以在 Github 上获取接入服务的 SDK 示例: