问题与““ https://docs.microsoft.com/en-us/azure/iot-dps/quick-create-simulated-device-x509-python”有关
“ https://docs.microsoft.com/en-us/azure/iot-dps/quick-create-simulated-device-x509-python#simulate-the-device”部分讨论了有关修改某些参数的问题。运行python代码时出现以下错误。
$ python provisioning_device_client_sample.py -i 0ne0007F9D9 -s X509 -p http
Python 2.7.12 (default, Nov 12 2018, 14:36:49)
[GCC 5.4.0 20160609]
Provisioning Device Client for Python
Starting the Provisioning Client Python sample...
Scope ID=0ne0007F9D9
Security Device Type X509
Protocol HTTP
Provisioning API Version: 1.2.12
Press Enter to interrupt...
Register status callback:
reg_status = CONNECTED
user_context = None
PUT /0ne0007F9D9/registrations/riot-device-cert/register?api-version=2018-09-01-preview HTTP/1.1
UserAgent: prov_device_client/1.0
Accept: application/json
Connection: keep-alive
Content-Type: application/json; charset=utf-8
Host: global.azure-devices-provisioning.net:443
content-length: 39
len: 39
{ "registrationId":"riot-device-cert" }
HTTP Status: 401
date: Thu, 26 Sep 2019 18:48:49 GMT
content-type: application/json; charset=utf-8
transfer-encoding: chunked
x-ms-request-id: 883b82ee-f696-4e68-9aec-61abc1e4a55b
strict-transport-security: max-age=31536000; includeSubDomains
{"errorCode":401002,"trackingId":"883b82ee-f696-4e68-9aec-61abc1e4a55b","message":"CA certificate not found.","timestampUtc":"2019-09-26T18:48:50.364959Z"}
Error: Time:Thu Sep 26 14:48:50 2019 File:/usr/sdk/src/c/provisioning_client/src/prov_device_ll_client.c Func:prov_transport_process_json_reply Line:323 failure retrieving json auth key value
Error: Time:Thu Sep 26 14:48:50 2019 File:/usr/sdk/src/c/provisioning_client/src/prov_transport_http_client.c Func:prov_transport_http_dowork Line:941 Unable to process registration reply.
Error: Time:Thu Sep 26 14:48:50 2019 File:/usr/sdk/src/c/provisioning_client/src/prov_device_ll_client.c Func:on_transport_registration_data Line:572 Failure retrieving data from the provisioning service
Register device callback:
register_result = PARSING
iothub_uri = None
user_context = None
Device registration failed!
我找不到应该复制设备证书的位置。可能是我的理解是错误的。帮我纠正它。
谢谢, Sreeju
答案 0 :(得分:1)
您是否像在previous step中提到的那样使用Visual Studio来构建项目?如果是这样,VS应该会为您连接,这样您就不必在一端复制证书,只需使用该证书在AzIotHub一侧设置设备即可。
要解决为什么没有发生这种情况,可以添加或链接自己构建的provisioning_device_client_sample.py
文件吗?它可能显示或指向X509SecurityClient
类的实例化位置,这将导致X509
对象,该对象的属性(self._cert_file
)将显示文件路径。如果您可以在python IDE中运行它,也可以帮助我们在控制台上进行加载。
如果这样做不方便,我可以自己构建SDK /示例并运行它,但是我已经很长时间没有在VM上打开Visual Studio了,可能可能需要经过一些许可协议。 (我主要使用不需要构建较新版本的IOTHub设备和服务SDK,或者使用SDK可能无法使用的区域的REST api。)在我有一些空闲时间之前,需要花费一些时间。那。