尝试使用 IoT 中心设备预配服务注册设备时出现无效 CN 错误

Invalid CN error when trying to enroll device using IoT Hub Device Provisioning Service

我正在尝试向 Azure IoT DPS 注册假冒设备。这是我第一次尝试使用 DPS。 我为以下内容添加了 X.509 自签名证书,并使用 'proof of possession' 技术让 Azure 对其进行了验证。

  1. 物联网中心
  2. DPS 本身

我正在尝试为设备添加叶证书。叶证书使用 DPS 证书作为其 CA。 (下面使用的命令)。 我收到一个错误 -

The CN (common name) in the primary certificate is invalid.

我读到设备注册 ID 必须与 CN 相同。所以在某个地方使用的 CN 需要修改,或者需要有一种方法可以指定与我的 CNAME 相同的注册 ID。

有人可以帮助解决这些问题 --

  1. DPS上哪里可以指定设备注册id?添加注册页面没有此字段。设备 ID 在那里,但它是可选字段。如果未输入,设备 ID 将根据文档设置为注册 ID 本身。
  2. 对于叶证书,CN 可以是任何有效的通用名称标识符,还是应该包含更多详细信息,如根 CA 名称等? (对于设备注册 id 需要是字母数字,小写,可以包含连字符)。

用于生成证书的命令:

makecert -r -pe -n "CN=Sam-DPS.azure-devices-provisioning.net" -cy authority -sky signature -sv Sam-DPS.pvk Sam-DPS.cer

makecert -pe -n "CN=hl1234" -cy end -sky signature -ic Sam-DPS.cer -iv Sam-DPS.pvk -sv hl1234.pvk hl1234.cer
  1. Where can device registration id be specified on DPS? Add enrollment page does not have this field. Device id is there, but it is optional field. IF not entered, device id will be set to registration id itself, as per documentation.

您不能在 Azure 门户中指定注册 ID。对于 x509,当您上传叶证书并成功添加个人注册时,registration id 自动从证书的主题名称 (CN) 开始。设备 ID 是在 IoT 中心显示的 ID。您可以使用从 IoT 中心创建的设备 ID 或将其留空,然后在您注册此设备时将其分配给注册 ID。注册成功后会在物联网中心看到。

  1. For a leaf certificate, can CN be any valid common name identifier, or it should contain more details like root CA name etc.? (For the device registration id needs to be alphanumeric, lowercase, may contain hyphens).

叶证书的 CN 不需要与根 CA 关联。但是,因为注册id作为证书的主题名称提供,所以CN需要遵循注册id的规则:

注册 ID 为字母数字、小写字母,并且可以包含连字符。

我测试"hl1234"作为设备叶子证书CN,有效。

您可以检查 this 以创建叶证书。