Upload a Device CA Certificate
Function
This API is used by an application to upload a device CA certificate to the IoT platform.
Debugging
You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.
URI
POST /v5/iot/{project_id}/certificates
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Project ID. For details about how to obtain the project ID, see Obtaining a Project ID. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
No |
String |
User token. You can obtain the token by calling the IAM API Obtaining a User Token Through Password Authentication. X-Subject-Token in the response header returned by the API is the desired user token. For details about how to obtain the token, see Token Authentication. |
Instance-Id |
No |
String |
Instance ID. Unique identifier of each instance in the physical multi-tenant scenario. Mandatory for professional editions and recommended in other cases. Log in to the IoTDA console and choose Overview in the navigation pane to view the instance ID. For details, see Viewing Instance Details. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
content |
Yes |
String |
Certificate content. Minimum: 1 Maximum: 65535 |
app_id |
No |
String |
Resource space ID. This parameter is optional. If you have multiple resource spaces, you can use this parameter to specify the resource space to which the certificate to create will belong. If this parameter is not specified, the certificate to create will belong to the default resource space. |
Response Parameters
Status code: 201
Parameter |
Type |
Description |
---|---|---|
certificate_id |
String |
Unique CA certificate ID, allocated by the platform when the certificate is uploaded. |
cn_name |
String |
CN of the CA certificate. |
owner |
String |
Owner of the CA certificate. |
status |
Boolean |
Verification status of the CA certificate. true indicates that the certificate has been verified and can be used for device access authentication. false indicates that the certificate does not pass the verification. |
verify_code |
String |
Verification code of the CA certificate. |
provision_enable |
Boolean |
Whether to enable the self-registration capability. The options are true (yes) and false (no). If this parameter is set to true, this function must be used together with the pre-provisioning function. |
template_id |
String |
ID of the bound pre-provisioning template. |
create_date |
String |
Time when the certificate was created. The value is in the format of yyyyMMdd'T'HHmmss'Z', for example, 20151212T121212Z. |
effective_date |
String |
Time when the CA certificate starts to take effect. The value is in the format of yyyyMMdd'T'HHmmss'Z', for example, 20151212T121212Z. |
expiry_date |
String |
Time when CA certificate expires. The value is in the format of yyyyMMdd'T'HHmmss'Z', for example, 20151212T121212Z. |
Example Requests
Uploads a device CA certificate.
POST https://{endpoint}/v5/iot/{project_id}/certificates { "content" : "-----BEGINCERTIFICATE-----\nMIID2TCCAsGgAwIBAgIJAOEDEgVdVMn9MA0GCSqGSIb3DQEBCwUAMIGCMQswCQYD\nVQQGEwJDTjERMA8GA1UECAwIR3VhbmRvbmcxETAPBgNVBAcMCFNoZW56aGVuMQ8w\nDQYDVQQKDAZIdWF3ZWkxDDAKBgNVBAsMA2lvdDESMBAGA1UEAwwJMTIzNDU2Nzg5\nMRowGAYJKoZIhvcNAQkBFgtkamthQHFxLmNvbTAeFw0xOTEyMTkxMzE1MjZaFw0y\nMjEwMDgxMzE1MjZaMIGCMQswCQYDVQQGEwJDTjERMA8GA1UECAwIR3VhbmRvbmcx\nETAPBgNVBAcMCFNoZW56aGVuMQ8wDQYDVQQKDAZIdWF3ZWkxDDAKBgNVBAsMA2lv\ndDESMBAGA1UEAwwJMTIzNDU2Nzg5MRowGAYJKoZIhvcNAQkBFgtkamthQHFxLmNv\nbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAM72QUzoadvLfxGjt3UF\noZ4MJbblqnRbouO4KpOVHBXyS2yQVl4CWWMhLh4pp2efNUSqKuXHjY3r68PquyNn\nYk8zO59zVc7JHvjGkBvo7DgPRAhEKPLJIpRzkmlCBbxwTNCjc3FovGb/sHHNlpGn\ncCKUzMfPGNZuBiuemskuEXL/eMHxDPbXYWn4Wq0wt+28PKUL5jybY7nsXSNnmAPF\nTO0CAmq0meUukubT/jHDCQ78ihQ/iqw1RNq88aCqRleoHiGg5nWkjL+05GXqUrqV\nVnZNL+YqcXzuVMs5XgyhNM2AsuH2g3D8ZuF6Dj9qY1n/v/Cp/DGpxP3A74SlplnF\nD/0CAwEAAaNQME4wHQYDVR0OBBYEFAVPWVtpTdO6KQnmVrrNlMguWNR7MB8GA1Ud\nIwQYMBaAFAVPWVtpTdO6KQnmVrrNlMguWNR7MAwGA1UdEwQFMAMBAf8wDQYJKoZI\nhvcNAQELBQADggEBAE40ViqK+UaEn++Xq6f4Cmeg3JqYHu47v9RIAASNihYRBQ/r\n3RE7Af3GqjIO5nMJJuCMzdcoAU8N9KwkgXD+GLR9fYLEoEmq5CrhgaGDsCi85vCs\nmWhj5z8r5TG207xpmvH2KT447dnG+chMBE594ma85dCv+0mCDrqNToElipgT8+rY\nAYVClnIt3kbsTg1vSRNHadd+TpgRVxJZBF0fHcCAyc/2f3UJgPYNWShIetHM6BdI\n3fZ4H+eeHPjagm5kzmffli1cUv2/N+1hKUvcI4uFCqEwZRFtp90RyIbxUfQwi+Cs\nXVnwV+BZS5qD9bTcfxZMXhuVRwO/5xWYMYPN1uY=\n-----END CERTIFICATE-----", "app_id" : "jeQDJQZltU8iKgFFoW060F5SGZka" }
Example Responses
Status code: 201
Created
{ "certificate_id" : "string", "cn_name" : "string", "owner" : "string", "status" : true, "verify_code" : "string", "create_date" : "20191212T121212Z", "effective_date" : "20191212T121212Z", "expiry_date" : "20221212T121212Z", "provision_enable" : true, "template_id" : "61c970ce2d63eb6ee655dbf0" }
Status Codes
Status Code |
Description |
---|---|
201 |
Created |
401 |
Unauthorized |
403 |
Forbidden |
400 |
Bad Request |
500 |
Internal Server Error |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot