Browse Source

lwm2m: fix bootstrap-short-server-id = null - comments 1

pull/16133/head
nickAS21 2 months ago
parent
commit
fcaeec8c2c
  1. 2
      application/src/main/resources/thingsboard.yml
  2. 5
      common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/bootstrap/secure/LwM2MBootstrapConfig.java
  3. 8
      dao/src/main/java/org/thingsboard/server/dao/service/validator/DeviceProfileDataValidator.java
  4. 2
      transport/lwm2m/src/main/resources/tb-lwm2m-transport.yml

2
application/src/main/resources/thingsboard.yml

@ -1344,7 +1344,7 @@ transport:
bootstrap: bootstrap:
# Enable/disable Bootstrap Server # Enable/disable Bootstrap Server
enabled: "${LWM2M_ENABLED_BS:true}" enabled: "${LWM2M_ENABLED_BS:true}"
# Short Server ID for Bootstrap Server is not applicable according to OMA LwM2M spec (Object 0 Resource 10 must be omitted/null for Bootstrap Server). # Short Server ID for Bootstrap Server is not applicable according to OMA LwM2M spec (Object 0 Resource 10 must be omitted/null); left empty by default, and any provided value is normalized to null by the validator upon save.
id: "${LWM2M_SERVER_ID_BS:}" id: "${LWM2M_SERVER_ID_BS:}"
# LwM2M bootstrap server bind address. Bind to all interfaces by default # LwM2M bootstrap server bind address. Bind to all interfaces by default
bind_address: "${LWM2M_BS_BIND_ADDRESS:0.0.0.0}" bind_address: "${LWM2M_BS_BIND_ADDRESS:0.0.0.0}"

5
common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/bootstrap/secure/LwM2MBootstrapConfig.java

@ -51,7 +51,7 @@ public class LwM2MBootstrapConfig implements Serializable {
* clientSecretKey?: string, * clientSecretKey?: string,
* serverPublicKey?: string; * serverPublicKey?: string;
* clientHoldOffTime?: number, * clientHoldOffTime?: number,
* serverId?: number, * shortServerId?: number for DM server; null for BS server,
* bootstrapServerAccountTimeout: number * bootstrapServerAccountTimeout: number
* */ * */
@Getter @Getter
@ -127,6 +127,9 @@ public class LwM2MBootstrapConfig implements Serializable {
private BootstrapConfig.ServerConfig setServerConfig (AbstractLwM2MBootstrapServerCredential serverCredential) { private BootstrapConfig.ServerConfig setServerConfig (AbstractLwM2MBootstrapServerCredential serverCredential) {
BootstrapConfig.ServerConfig serverConfig = new BootstrapConfig.ServerConfig(); BootstrapConfig.ServerConfig serverConfig = new BootstrapConfig.ServerConfig();
if (!serverCredential.isBootstrapServerIs()) {
serverConfig.shortId = serverCredential.getShortServerId();
}
serverConfig.lifetime = serverCredential.getLifetime(); serverConfig.lifetime = serverCredential.getLifetime();
serverConfig.defaultMinPeriod = serverCredential.getDefaultMinPeriod(); serverConfig.defaultMinPeriod = serverCredential.getDefaultMinPeriod();
serverConfig.notifIfDisabled = serverCredential.isNotifIfDisabled(); serverConfig.notifIfDisabled = serverCredential.isNotifIfDisabled();

8
dao/src/main/java/org/thingsboard/server/dao/service/validator/DeviceProfileDataValidator.java

@ -380,14 +380,8 @@ public class DeviceProfileDataValidator extends AbstractHasOtaPackageValidator<D
throw new DeviceCredentialsValidationException("Only one Bootstrap Server configuration is allowed!"); throw new DeviceCredentialsValidationException("Only one Bootstrap Server configuration is allowed!");
} }
// 2. Reject if DM (LwM2M) Server ports are used for Bootstrap Server
int dmPort = LwM2MSecurityMode.NO_SEC.equals(serverConfig.getSecurityMode()) ? lwm2mPort : lwm2mSecurePort;
if (serverConfig.getPort() != null && serverConfig.getPort() == dmPort) {
log.error("Invalid Bootstrap Server configuration: uses DM Server port [{}]", serverConfig.getPort());
throw new DeviceCredentialsValidationException("Bootstrap Server configuration cannot use DM Server port " + serverConfig.getPort());
}
// 3. Normalize legacy shortServerId to null for backward compatibility // 2. Normalize legacy shortServerId to null for backward compatibility
if (serverConfig.getShortServerId() != null) { if (serverConfig.getShortServerId() != null) {
log.warn("Ignoring Short Server ID [{}] on the Bootstrap Server entry: cleared to null for backward compatibility (ThingsBoard <= 4.2).", log.warn("Ignoring Short Server ID [{}] on the Bootstrap Server entry: cleared to null for backward compatibility (ThingsBoard <= 4.2).",
serverConfig.getShortServerId()); serverConfig.getShortServerId());

2
transport/lwm2m/src/main/resources/tb-lwm2m-transport.yml

@ -227,7 +227,7 @@ transport:
bootstrap: bootstrap:
# Enable/disable Bootstrap Server # Enable/disable Bootstrap Server
enabled: "${LWM2M_ENABLED_BS:true}" enabled: "${LWM2M_ENABLED_BS:true}"
# Short Server ID for Bootstrap Server is not applicable according to OMA LwM2M spec (Object 0 Resource 10 must be omitted/null for Bootstrap Server). # Short Server ID for Bootstrap Server is not applicable according to OMA LwM2M spec (Object 0 Resource 10 must be omitted/null); left empty by default, and any provided value is normalized to null by the validator upon save.
id: "${LWM2M_SERVER_ID_BS:}" id: "${LWM2M_SERVER_ID_BS:}"
# LwM2M bootstrap server bind address. Bind to all interfaces by default # LwM2M bootstrap server bind address. Bind to all interfaces by default
bind_address: "${LWM2M_BS_BIND_ADDRESS:0.0.0.0}" bind_address: "${LWM2M_BS_BIND_ADDRESS:0.0.0.0}"

Loading…
Cancel
Save