【问题标题】:How to connect X.509 authenticated downstream device using azure python sdk version 2 to azure edge enabled gateway如何使用 azure python sdk 版本 2 将经过 X.509 身份验证的下游设备连接到启用了 azure edge 的网关
【发布时间】:2020-03-24 10:59:52
【问题描述】:

使用现已弃用的 azure-iot-python-skd 版本 1,可以通过如下设置连接字符串,将使用 X.509 身份验证的下游设备连接到启用了透明 iotedge 的网关: HostName=<edge device hostname>;DeviceId=<device_id>;x509=true

然后使用set_option("TrustedCerts" ...)set_option("x509certificate", ...)set_option("x509privatekey", ...)设置证书

如何使用新版本 2 sdk 做到这一点?

我不知道如何使用create_from_x509_certificate(...)create_from_connection_string(...) 来做这件事。

【问题讨论】:

    标签: azure-iot-hub azure-iot-sdk


    【解决方案1】:

    请在您将 root_ca_cert 作为字符串传递的地方尝试以下操作:

    使用连接字符串创建设备客户端实例:

    device_client = IoTHubDeviceClient.create_from_connection_string(connection_string=YOUR CONNECTION STRING,server_verification_cert=YOUR ROOT CA AS STRING)

    等待 device_client.connect()

    【讨论】:

    • 遗憾的是这不起作用,因为下游设备使用 x509 CA 身份验证,而不是您建议的连接字符串。
    • 抱歉,我不确定我是否理解这个问题...如果通过 x509 证书进行身份验证,您可以从连接字符串中使用的证书创建设备客户端。请参阅此示例:github.com/Azure/azure-iot-sdk-python/blob/master/…
    【解决方案2】:

    create_from_connection_string 在这种情况下不起作用。您需要使用create_from_x509_certificate,如下所示:-

    self.device_client = IoTHubDeviceClient.create_from_x509_certificate(
               x509=x509, 
               hostname=hostname,
               device_id=device_id,
               server_verification_cert=root_ca_cert,
               gateway_hostname=gatewayHostname
    )
    

    请参阅 ticket,这是 MS 团队完成的错误修复

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-10
      • 2014-11-07
      • 1970-01-01
      • 1970-01-01
      • 2011-09-10
      相关资源
      最近更新 更多