更新时间:2025-11-27 GMT+08:00

添加服务器证书

功能介绍

应用服务器可调用此接口在物联网平台上添加服务器证书,服务器证书配额限制为:2个。

调试

您可以在API Explorer中调试该接口,支持自动认证鉴权。API Explorer可以自动生成SDK代码示例,并提供SDK代码示例调试功能。

URI

POST /v5/iot/{project_id}/server-certificates

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

参数说明:项目ID。获取方法请参见 获取项目ID

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

Instance-Id

String

参数说明:实例ID。物理多租下各实例的唯一标识,建议携带该参数,在使用专业版时必须携带该参数。您可以在IoTDA管理控制台界面,选择左侧导航栏“总览”页签查看当前实例的ID,具体获取方式请参考 查看实例详情

表3 请求Body参数

参数

是否必选

参数类型

描述

certificate_pem

String

参数说明:证书内容,PEM格式。

取值范围:合法PEM格式证书内容,长度不超过65535。

private_key

String

参数说明:证书私钥。

取值范围:合法私钥内容,长度不超过10240。

private_key_password

String

参数说明:私钥密码。

取值范围:只支持英文字符,长度不超过64。

响应参数

状态码:201

表4 响应Body参数

参数

参数类型

描述

server_certificate_id

String

唯一标识ID

common_name

String

参数说明:证书通用名

effective_date

String

证书生效日期。格式:yyyyMMdd'T'HHmmss'Z',如20151212T121212Z。

expiry_date

String

证书失效日期。格式:yyyyMMdd'T'HHmmss'Z',如20151212T121212Z。

certificate_owner

String

证书所有者。

certificate_issuer

String

证书颁发者。

请求示例

添加服务器证书。

POST https://{endpoint}/v5/iot/{project_id}/server-certificates

{
  "certificate_pem" : "-----BEGINCERTIFICATE-----\nMIID2TCCAsGgAwIBAgIJAOEDEgVdVMn9MA0GCSqGSIb3DQEBCwUAMIGCMQswCQYD\nVQQGEwJDTjERMA8GA1UECAwIR3VhbmRvbmcxETAPBgNVBAcMCFNoZW56aGVuMQ8w\nDQYDVQQKDAZIdWF3ZWkxDDAKBgNVBAsMA2lvdDESMBAGA1UEAwwJMTIzNDU2Nzg5\nMRowGAYJKoZIhvcNAQkBFgtkamthQHFxLmNv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LqjGr2ETsPy\nCK62webYw7I3ITqkZU8zRm6phQuaS5IJK7ubnHYNMx+xcFWsssHrzMEjLnbSCM0D\nwQ0x/gPHl+okRe33FQO51jEQ+OxJglNlWxpi6x8CgYEAzAVArcMHK+V33L4L+5gP\n1BGTbknZAdPEBG/3ql+UTzRSHpqDDqRW/8ge4fZsWbeJyoRcs3qUuktXakJoVs2Q\nBLq3PtzyHjYNc/qA4hDbFLn9VOf9OxVUJaiobY0Y6LM9wZcxKTcDXv8TFfCpK19V\neXXryqeoXcJ328jd7+c8thkCgYEAvRByU0tI73eheig180VhQVqr3fhA7L+Snz4X\npnQRBIsB+RJmo9JdELbHwDS87R2ODBaOvwHzIKwP2JwKkB5Lv0BqrFmkZJ2XBZJ6\nVZx92GbY5jjfIHOBUNlnEgxkR8xLewInEqdCVd5QL2D4sRu3ugbr44TKO56T+PUh\nt2Y0j2sCgYBpMV9Z1WWdqm7sR/Mh41kLmEdbANgElIyMellEqvCUE7Dh5b44VVkj\nDJkKWwfJtjUaJSd6SHzNTtvF3RAjTcp4kxaVqkMuK11w+bQNpJKk3lGvyCC5eH2U\nVwS2lC+WRlApFQBxdNu5Hf7gvlSW6E2yplBdHj9TED/WUpFNFazG0w==\n-----END RSA PRIVATE KEY-----"
}

响应示例

状态码:201

Created

{
  "server_certificate_id" : "60f8c49169d4840337930a4b",
  "common_name" : "iotda",
  "certificate_pem" : "-----BEGINCERTIFICATE-----\nMIID2TCCAsGgAwIBAgIJAOEDEgVdVMn9MA0GCSqGSIb3DQEBCwUAMIGCMQswCQYD\nVQQGEwJDTjERMA8GA1UECAwIR3VhbmRvbmcxETAPBgNVBAcMCFNoZW56aGVuMQ8w\nDQYDVQQKDAZIdWF3ZWkxDDAKBgNVBAsMA2lvdDESMBAGA1UEAwwJMTIzNDU2Nzg5\nMRowGAYJKoZIhvcNAQkBFgtkamthQHFxLmNvbTAeFw0xOTEyMTkxMzE1MjZaFw0y\nMjEwMDgxMzE1MjZaMIGCMQswCQYDVQ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FICATE-----",
  "effective_date" : "20251212T121212Z",
  "expiry_date" : "20301212T121212Z",
  "certificate_owner" : "CN=Huawei Cloud Core Network Product CA, O=Huawei, C=CN",
  "certificate_issuer" : "CN=Huawei Cloud Core Network Product CA, O=Huawei, C=CN"
}

状态码

状态码

描述

201

Created

401

Unauthorized

403

Forbidden

400

Bad Request

500

Internal Server Error

错误码

请参见错误码