Renew Certificate¶
Update a certificate and bind the updated one with the device.
Operation Permissions¶
Required Authorization |
Required Operation Permission |
---|---|
Device Management |
Full Access |
Request Format¶
POST http://{apigw-address}/connect-service/v2.0/certificates?action=renew
Request Parameters (URI)¶
Note
One of the following options must be used in a request to specify a device
assetId
productKey
+deviceKey
Name |
Location (Path/Query) |
Required or Not |
Data Type |
Description |
---|---|---|---|---|
orgId |
Query |
True |
String |
Organization ID which the asset belongs to. How to get Organization ID>> |
assetId |
Query |
false |
String |
Asset ID of the device |
productKey |
Query |
false |
String |
Product key of the device |
deviceKey |
Query |
false |
String |
Device key of the device |
certSn |
Query |
True |
int |
The number of the certificate to be updated |
validDay |
Query |
False |
int |
The validity period of the certificate in days. If this parameter is not included in the request. It will be inferred that you specified the default value, 730. Certain rules as follows apply to this parameter. |
Rules for the Validity Period of a Certificate¶
To validDay
in a request, the following rules apply:
If the specified or default value (730) is less than the maximum validity period of the product that this device belongs to, the specified value or the default value shall be applied.
If the specified or default value (730) is greater than the maximum validity period of the product that this device belongs to, an error message is prompted and the application fails.
If the specified is greater than the default value, less than the maximum validity period of the product that this device belongs to, but exceeds the remaining CA root certificate validity, the CA root certificate validity period shall be applied.
Request Parameters (Body)¶
Name |
Required or Not |
Data Type |
Description |
---|---|---|---|
csr |
False |
String |
CSR file (Certificate Signing Request) in the Privacy-Enhanced Mail (PEM) format. If this parameter is not included in the request, a certificate will be generated based on previous request data. |
Response Parameters¶
Name |
Data Type |
Description |
---|---|---|
data |
DeviceCertRenewResultInfo object |
Certificate binding information. See the table below for its structure. |
DeviceCertRenewResultInfo Object¶
Name |
Data Type |
Description |
---|---|---|
certChainURL |
String |
CA root certificate URL |
cert |
String |
The content of the certificate obtained |
certSn |
String |
Certificate number |
caCert |
String |
CA root certificate |
Sample¶
Java SDK Sample¶
package com.envisioniot.enos.api.sample.connect_service.cert;
import com.envision.apim.poseidon.config.PConfig;
import com.envision.apim.poseidon.core.Poseidon;
import com.envisioniot.enos.connect_service.v2_1.cert.RenewCertificateRequest;
import com.envisioniot.enos.connect_service.v2_1.cert.RenewCertificateResponse;
import com.envisioniot.enos.connect_service.vo.DeviceIdentifier;
public class RenewCert {
public static void main(String[] args) {
String appKey = "e36cc693-3a07-456e6cafcbc2-9314-4ff6";
String appSecret = "6cafcbc2-9314-4ff6-9450-861d4344a431";
String serverUrl = "http://apim-apigw-proxy.alpha-k8s-cn4.eniot.io";
String orgId = "o15444172373271";
String newCert = "-----BEGIN NEW CERTIFICATE REQUEST-----\n" +
"MIICwTCCAakCAQAwfDELMAkGA1UEBhMCQ04xETAPBgNVBAgMCFNoYW5naGFpMREw\n" +
"DwYDVQQHDAhTaGFuZ2hhaTENMAsGA1UECgwERW5PUzERMA8GA1UEAwwITVJtSXl6\n" +
"UFcxDTALBgNVBAsMBEVuT1MxFjAUBgkqhkiG9w0BCQEWBzREbmIxVDEwggEiMA0G\n" +
"CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC+dU5jLAu7Kb88hONou6PycTnv9+3/\n" +
"FFPaHm5I8vPfhh0QL6TcunKpm97Dyds1yHgMCqVT+gWgO4MHFz8TiIb9JKRjHn/6\n" +
"kFea1ccZU9nYGuv+yMGqa340NjN/vP+XpjXm6Xkqw7ujehhNoBuKJZh6+uXlf2yw\n" +
"1gTP9vWJTc7cuiky2jgKl6/47iKEmIMT1xpHVDp16LWX08/aamJESPJ171RFFxf/\n" +
"6z2taiK/z7McXFRHk+SdYGN0iTNZQqoFKi3S9S8FvkLBQF8gHOytZdpnSz6SZwW0\n" +
"DJUv8VGFWQYOVU67BzVR59s0CVM9IdAHntjXm2t3BF0A9kKZa6VDzHpxAgMBAAGg\n" +
"ADANBgkqhkiG9w0BAQsFAAOCAQEASGPYV0t4zPT3XA42SKqNzNEiYvB550/6Vh1y\n" +
"mxD+mQXeyvkZn5OcxtuzrgD7aBVRcT/j+tK4XP8s+ODYiM+VSrqLs+a5ZGmOhHHf\n" +
"36MdmAK8I/dNyHZBiTf+GI5ibul2vaSpYYUwarzMu0azT6+d2qiUl7TqVVIGo4+P\n" +
"PSRp+V+9e4RJ/TKUjAToBazz154tXU5psVmQ1Ac9oF7Y/9AvGTtusLUDHCu3T45J\n" +
"QiwAUsMkSla5HCZEftNV8uC+BR6GktfFGLv3Gx+havoBsi82OPDUbBBtKgbiIQyq\n" +
"bslaLc4GkDZTZPz4st7/ChYOZVJNxz2CAx1JU4VAfjonqChzbw==\n" +
"-----END NEW CERTIFICATE REQUEST-----";
Integer certSn = 2667;
RenewCertificateRequest request = new RenewCertificateRequest();
request.setCertSn(certSn);
request.setCsr(newCert);
request.setValidDay(220);
DeviceIdentifier identifier = new DeviceIdentifier();
identifier.setProductKey("ymcDiAHd");
identifier.setAssetId("KloXinjW");
identifier.setDeviceKey("TT6MyEFaO7");
request.setDevice(identifier);
request.setOrgId(orgId);
RenewCertificateResponse certRsp = Poseidon.config(PConfig.init().appKey(appKey).appSecret(appSecret).debug())
.url(serverUrl)
.getResponse(request, RenewCertificateResponse.class);
System.out.println(certRsp.getData());
}
}
Error Code¶
Error Code |
Type |
Description |
---|---|---|
99400 |
|
|
11404 |
device can not be found |
No device can be found by either |
11833 |
certificate already bind to another device |
The certificate has been bound to another device. |
99500 |
|
|