SDK Root Certificate Update Guide

Updated at:

Link SDK is a device-side software development kit provided by Alibaba Cloud IoT Platform. It simplifies development and enables devices to quickly connect to Alibaba Cloud IoT Platform. For more information, see the device access overview. This topic describes how to update the root certificate for each SDK. Update your code accordingly and perform sufficient verification.

C

4.x (including 4.0.0/4.1.0/4.2.0, etc.)

Check whether the SDK used in my previous product development is 4.x:

Before you upgrade, check whether the SDK used to develop your existing devices is 4.x. To do this, check whether the file core/utils/core_auth.h exists and contains the following content. If not, skip this section.

#define CORE_AUTH_SDK_VERSION "sdk-c-4.x.x"

SDK version:

See Download C-SDK to obtain the latest SDK.

Root certificate and TLS library:

The root certificate and the mbed TLS library are located in the external directory. You need to port both (or the entire SDK) to your development environment.

external/
├── ali_ca_cert.c
└── mbedtls

The SDK provides many atomic capabilities. Determine how to upgrade based on the atomic capabilities that you actually use.

MQTT/Thing Specification (TSL):

Find the place in your existing code where the AIOT_MQTTOPT_PORT option is used, and change the port value:

const uint16_t port = 8883;
aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_PORT, (void *)&port);
Note

If your device is already connected to IoT Platform through port 8883 and does not use features such as HTTP, bootstrap, CoAP, and OTA described below, you do not need to update the device firmware.

HTTP-based dynamic registration (see demos/dynreg_basic_demo.c):

Add the following two lines to your existing code to change the host from iot-auth.{region}.aliyuncs.com to iot-auth-x.{region}.aliyuncs.com. For example:

char       *host = "iot-auth-x.cn-shanghai.aliyuncs.com"; 

int res = aiot_dynreg_setopt(dynreg_handle, AIOT_DYNREGOPT_HOST, (void *)host);

Bootstrap service (see demos/bootstrap_posix_demo.c):

You need to change the bootstrap endpoint from the default iot-auth-global.aliyuncs.com to iot-auth-global-x.aliyuncs.com. To do this, add the following two lines to your existing code:

char *bootstrap_host = "iot-auth-global-x.aliyuncs.com";

int res = aiot_bootstrap_setopt(bootstrap_handle, AIOT_BOOTSTRAPOPT_HOST, (void *)bootstrap_host);

CoAP (see demos/coap_basic_demo.c):

Add the following two lines to your existing code to change the host from iot-auth.{region}.aliyuncs.com to iot-auth-x.{region}.aliyuncs.com,

char  *host             = "iot-*****-x.coap.iothub.aliyuncs.com";

aiot_coap_setopt(coap_handle, AIOT_COAPOPT_HOST, host);

HTTP connection to IoT Platform (see demos/http_basic_demo.c):

You need to change the host from iot-as-http.{region}.aliyuncs.com to iot-as-http-x.{region}.aliyuncs.com。

OTA (see demos/fota_basic_demo.c):

You need to update external/ali_ca_cert.c and external/mbedtls.


2.3.0

Check whether the SDK used in my previous product development is 2.3.0:

Before you upgrade, check whether the SDK used to develop your existing devices is 2.3.0. To do this, check whether the file include/iot_export.h exists and contains the following content. If not, skip this section.

#define LINKKIT_VERSION     "2.3.0"

SDK download:

git clone https://github.com/aliyun/iotkit-embedded.git -b v2.3.0

Root certificate and TLS library:

The root certificate is located in src/infra/system/ca.c, and the mbedtls library is located in src/ref-impl/tls. You need to port both (or the entire SDK) to your development environment.

MQTT:

    int userPort=8883;
    IOT_Ioctl(IOTX_IOCTL_SET_MQTT_PORT, &userPort);

Dynamic registration and pre-authentication:

#define CUSTOME_DOMAIN_HTTP     "iot-auth-x.{region}.aliyuncs.com"

IOT_Ioctl(IOTX_IOCTL_SET_HTTP_DOMAIN, (void *)CUSTOME_DOMAIN_HTTP);

Replace the region field with the region of your IoT Platform instance.

OTA:

You do not need to modify your code, but make sure that the root certificate and the TLS library are updated as described above.


3.1.0/3.2.0

Check whether the SDK used in my previous product development is 3.1.0/3.2.0:

Before you upgrade, check whether the SDK used to develop your existing devices is 3.1.0/3.2.0. To do this, check whether the file ./src/infra/infra_defs.h exists and contains the following content. If not, skip this section.

#define IOTX_SDK_VERSION                "3.1.0"
Or
#define IOTX_SDK_VERSION                "3.2.0"

SDK download:

git clone https://github.com/aliyun/iotkit-embedded.git -b v3.2.0
git clone https://github.com/aliyun/iotkit-embedded.git -b v3.1.0

Root certificate and TLS library:

The root certificate is located in certs/root_ca.c, and the mbedtls library is located in external_libs/mbedtls. You need to port both (or the entire SDK) to your development environment.

MQTT:

    int userPort=8883;
    IOT_Ioctl(IOTX_IOCTL_SET_MQTT_PORT, &userPort);

Dynamic registration and pre-authentication:

#define CUSTOME_DOMAIN_HTTP     "iot-auth-x.{region}.aliyuncs.com"

IOT_Ioctl(IOTX_IOCTL_SET_HTTP_DOMAIN, (void *)CUSTOME_DOMAIN_HTTP);

Replace the region field with the region of your IoT Platform instance.

OTA:

You do not need to modify your code, but make sure that the root certificate and the TLS library are updated as described above.


3.0.1

Check whether the SDK used in my previous product development is 3.0.1:

Before you upgrade, check whether the SDK used to develop your existing devices is 3.0.1. To do this, check whether the file ./src/infra/infra_defs.h exists and contains the following content. If not, skip this section.

#define IOTX_SDK_VERSION                "3.0.1"

SDK download:

git clone https://github.com/aliyun/iotkit-embedded.git -b v3.0.1

MQTT connection, root certificate, and TLS library:

The root certificate is located in certs/root_ca.c, and the mbedtls library is located in external_libs/mbedtls. You need to port the entire SDK to your development environment, or modify your code based on the commit ID (0d3beeedb31a39f4b54fb4c521e8ce63f23e817c) on GitHub.

Dynamic registration and pre-authentication:

#define CUSTOME_DOMAIN_HTTP     "iot-auth-x.{region}.aliyuncs.com"

IOT_Ioctl(IOTX_IOCTL_SET_HTTP_DOMAIN, (void *)CUSTOME_DOMAIN_HTTP);

Replace the region field with the region of your IoT Platform instance.

OTA:

You do not need to modify your code, but make sure that the root certificate and the TLS library are updated as described above.


5.x Extended Edition

Check whether the SDK used in my previous product development is 5.x:

Before you upgrade, check whether the SDK used to develop your existing devices is 5.x. To do this, check whether the device-core and device-module folders exist. If not, skip this section.

SDK version:Get the SDK

  • Version: 1.0.1

  • Date: 2026-07-14

  • Download URL: https://linkkit-export.oss-cn-shanghai.aliyuncs.com/c-sdk-ext/publish/aliyun-iot-device-c-extend-1.0.1.zip

  • New features: 1. Supports and uses the new certificate domain by default. 2. Adds the R46 certificate.


Other versions of C-SDK:

If your SDK is not covered above, submit a ticket for consultation.

Android SDK

SDK version:

1.7.3.5 or later. See Release notes.

User code changes:

  • MQTT connection to IoT Platform:

    See Authentication and connection and use port 8883.

    MqttConfigure.mqttHost = "{YourInstanceId}.mqtt.iothub.aliyuncs.com:8883";
    
    Or
    
    IoTMqttClientConfig clientConfig = new IoTMqttClientConfig();
    clientConfig.channelHost = "a18wP******.iot-as-mqtt.cn-shanghai.aliyuncs.com:8883";
    linkKitInitParams.mqttClientConfig = clientConfig;  
  • Dynamic registration:

    If your code uses the deprecated dynamic registration interface (based on the HTTP protocol)

     deviceRegister(LinkKitInitParams initParams, CommonRequest request, IoTCallback listener)

    Use the new MQTT-based dynamic registration interface instead

    deviceDynamicRegister(MqttInitParams initParams, IOnCallListener listener)

    For more information about how to use it, see Authentication and connection.

  • HTTP/2 file upload:

    If you use HTTP/2 file upload, explicitly set ioTH2Config.endPoint to the file upload endpoint for your instance. The endpoint must include the -x field.

    IoTH2Config ioTH2Config = new IoTH2Config();
    ioTH2Config.clientId = "client-id";
    ioTH2Config.endPoint = "https://" + productKey + "-x.iot-as-http2.{region_id}.aliyuncs.com:443"; // Production environment. Replace {region_id} with the Region ID of your instance.
    params.iotH2InitParams = ioTH2Config;

Python SDK

SDK version:

1.2.11 or later. See Release notes.

User code changes:

  • MQTT connection to IoT Platform:

    See Authentication and connection and use port 8883.

    lk.config_mqtt(port=8883, protocol="MQTTv311", transport="TCP",
                secure="TLS", keep_alive=60, clean_session=True,
                max_inflight_message=20, max_queued_message=0,
                auto_reconnect_min_sec=1,
                auto_reconnect_max_sec=60,
                check_hostname=True,   
                cadata=None)
  • Dynamic registration:

    If your code uses the deprecated dynamic registration method (device_secret is an empty string or is not set, and the auth_type field is an empty string or is not set).

    lk_auth = linkkit.LinkKit(
        host_name="cn-shanghai",
        product_key=product_key,
        device_name=device_name,
        device_secret="",
        auth_type="",
        instance_id=instance_id,
        product_secret=product_secret)

    Set auth_type to "register" to use the new MQTT-based dynamic registration method.

Java SDK

SDK version:

1.2.3.7 or later. See Release notes.

User code changes:

  • MQTT connection to IoT Platform:

    See Authentication and connection and use port 8883.

    MqttConfigure.mqttHost = "{YourInstanceId}.mqtt.iothub.aliyuncs.com:8883";
    
    Or
    
    IoTMqttClientConfig clientConfig = new IoTMqttClientConfig();
    clientConfig.channelHost = "a18wP******.iot-as-mqtt.cn-shanghai.aliyuncs.com:8883";
    linkKitInitParams.mqttClientConfig = clientConfig;  
  • Dynamic registration:

    If your code uses the deprecated dynamic registration interface (based on the HTTP protocol)

     deviceRegister(LinkKitInitParams initParams, CommonRequest request, IoTCallback listener)

    Use the new MQTT-based dynamic registration interface instead

    deviceDynamicRegister(MqttInitParams initParams, IOnCallListener listener)

    For more information about how to use it, see Authentication and connection.

iOS SDK

SDK version:

No change

User code changes:

  • MQTT connection to IoT Platform:

    Follow the protocol documentation to change the access domain. See the existing Authentication and connection. The referenced access method is as follows:

    #import <IotLinkKit/IotLinkKit.h>
    
        // Before initialization, register a listener to listen for connection status changes of the persistent connection channel
        [[LinkKitEntry sharedKit] registerChannelListener:self];
    
        //// Enter the device authentication information
        self.productKey = self.textFieldProductKey.text ;
        self.deviceName = self.textFieldDeviceName.text ;
        self.deviceSecret = self.textFieldDeviceSecret.text;
    
        LinkkitChannelConfig * channelConfig = [[LinkkitChannelConfig alloc] init];
        channelConfig.productKey = self.productKey;
        channelConfig.deviceName = self.deviceName;
        channelConfig.deviceSecret = self.deviceSecret;
        channelConfig.cleanSession = (self.cleanSession == 1);
        //channelConfig.server = @"your custom server url";
        //channelConfig.port = 1883;
        LinkkitSetupParams * setupParams = [[LinkkitSetupParams alloc] init];
        setupParams.appVersion = self.appVersion;
        setupParams.channelConfig = channelConfig;
        [[LinkKitEntry sharedKit] setup:setupParams resultBlock:^(BOOL succeeded, NSError * _Nullable error) {
            LinkkitLogDebug(@"setup error : %@", error);
            dispatch_async(dispatch_get_main_queue(), ^{
                [self ims_showHUDWithMessage:[NSString stringWithFormat:@"Linkkit Initialization : %@",
                                              succeeded ? @"Succeeded" : @"Failed"]];
            });
        }];

    The channelConfig.server field on line 16 can no longer use the default value. You must explicitly point it to the new access address.

    • If your instance is a public instance (the device access domain is in the format a18wP******.iot-as-mqtt.cn-shanghai.aliyuncs.com), call channelConfig.server = a18wP********-x.iot-as-mqtt.cn-shanghai.aliyuncs.com in your code to specify the new endpoint. Note that the domain prefix must end with -x.

    • If your instance is an enterprise instance (the device access domain is in the format iot-06*****l.mqtt.iothub.aliyuncs.com), call channelConfig.server = iot-06*****l-x.mqtt.iothub.aliyuncs.com in your code to specify the new endpoint. Note that the domain prefix must end with -x.

JS SDK

SDK version:

No change

User code changes:

  • MQTT connection to IoT Platform:

    You need to explicitly specify brokerUrl.

    const iot = require('alibabacloud-iot-device-sdk');
    const device = iot.device({
      productKey: `${productKey}`,
      deviceName: `${deviceName}`,
      deviceSecret: `${deviceSecret}`,
      brokerUrl: `wss://${productKey}-x.iot-as-mqtt.${regionId}.aliyuncs.com:443`,
    });
    ​
    device.on('connect', () => {
      console.log('connect sucessfully!');
    });    

    Note that the brokerUrl field requires the -x suffix. For example, ${productKey}-x.iot-as-mqtt.${regionId}.aliyuncs.com (public instance), or "iot-******-x.http.iothub.aliyuncs.com" (enterprise instance).

  • Dynamic registration:

    You need to explicitly specify the registerURL field

    const iot = require('alibabacloud-iot-device-sdk');
    const params = {
      productKey: `${productKey}`,
      productSecret: `${productSecret}`,
      deviceName: `${deviceName}`,
      registerURL: 'https://iot-auth-x.cn-shanghai.aliyuncs.com/auth/register/device'
    };
    let device;
    iot.register(params, (res) => {
      console.log("register:", res);
      if (res.code == '200') {
        // res.data.deviceSecret is the DeviceSecret returned by IoT Platform. Keep the key confidential.
        // After the device successfully connects to IoT Platform by using its authentication information, you cannot use this function to obtain the DeviceSecret again.
        // Create a device object to connect to Alibaba Cloud IoT Platform
        device = iot.device({
          productKey: `${productKey}`,
          deviceName: `${deviceName}`,
          // res.data.deviceSecret is the DeviceSecret returned by IoT Platform
          deviceSecret: res.data.deviceSecret,
        });
      }
    });

    Note that the registerURL field requires the -x suffix.

    Content to add to package.json:

      "overrides": {
        "mqtt": "^4.3.8"
      }

Precautions

Make sure that SNI is enabled for the TLS library

The TLS library (mbedtls) of the current C-SDK has the SNI (Server Name Indication) feature enabled by default, which supports the new domains described above and CDN downloads from OSS. For more information, see the config.h file in the mbedtls library, where the following macro is enabled.

#define MBEDTLS_SSL_SERVER_NAME_INDICATION

If you use another TLS library, make sure that SNI is also enabled. Otherwise, the connection fails.