从 sgcWebSockets 4.4.3 起,Amazon AWS IoT MQTT 组件支持自定义身份验证,此版本起所有 MQTT 协议均已支持。
- 基于 WebSockets 的 MQTT
- 基于 TCP 的 MQTT
- X.509 证书身份验证
- Signature V4 身份验证
- 自定义身份验证
支持的协议
下表列出了 AWS IoT 设备端点支持的协议及其使用的身份验证方法和端口。

自定义身份验证
AWS IoT Core 允许您定义自定义授权程序,从而管理自己的客户端身份验证和授权。这在您需要使用 AWS IoT Core 原生不支持的身份验证机制时非常有用。 例如,如果您正在将现有设备迁移到 AWS IoT Core,而这些设备使用自定义 bearer token 或 MQTT 用户名和密码进行身份验证,您可以无需为其预置新身份即可将其迁移到 AWS IoT Core。自定义身份验证适用于 AWS IoT Core 支持的所有通信协议。
示例:若要使用 MQTT 用户名和密码进行身份验证
oIoT := TsgcIoTAmazon_MQTT_Client.Create(nil); oIoT.MQTTAuthentication.Enabled := True; oIoT.MQTTAuthentication.Username := 'user'; oIoT.MQTTAuthentication.Password := 'password'; oIoT.CustomAuthentication.Enabled := True; oIoT.CustomAuthentication.WebSockets := True; oIoT.CustomAuthentication.Parameters := '/mqtt'; oIoT.Active := True;
示例:若要发送 bearer token
oIoT := TsgcIoTAmazon_MQTT_Client.Create(nil); oIoT.CustomAuthentication.Enabled := True; oIoT.CustomAuthentication.WebSockets := True; oIoT.CustomAuthentication.Parameters := '/mqtt'; oIoT.CustomAuthentication.Headers.Text := 'Authorization: Bearer AbCdEf123456'; oIoT.Active := True;
