【发布时间】:2018-12-06 02:41:28
【问题描述】:
我使用.NET Core 2.1 编写了控制台应用程序。
这个应用的职责是:连接Azure IoT hub并发送数据。
我仍然低于异常
System.Net.WebSockets.WebSocketException (0x80004005): Unable to connect to the remote server ---> System.Net.Http.HttpRequestException: SSL 连接无法建立,见内部异常。 ---> System.Security.Authentication.AuthenticationException:根据验证程序,远程证书无效。 在 System.Net.Security.SslState.StartSendAuthResetSignal
注意:
- 我在 Windows Embedded Standard 上运行我的代码。
- 使用网络套接字
- 在 Windows 10 中运行良好
这是我的 nuget 参考
using Microsoft.Azure.Devices.Client;
using Microsoft.Azure.Devices.Shared;
这就是我创建连接的方式。
string deviceConnectionString = "*******";
_Client = DeviceClient.CreateFromConnectionString(deviceConnectionString, TransportType.Mqtt_WebSocket_Only);
Web 套接字在 Windows 7 上不起作用。参考:Using WebSocket on Windows 7
所以我使用 .NET Core 2.1 来获得 Web 套接字支持,正如这里提到的 https://github.com/dotnet/corefx/issues/20191
我还是遇到同样的错误!
下面是什么意思?
远程证书根据验证无效?
更新
.NET 运行时似乎无法调用较旧的 Windows Embedded Standard API 来验证 TLS 证书。我可能需要在 mycode 中这样做。
一些细节在https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-mqtt-support
另一个选项是编译 C SDK,它已经有这个 TLS 证书。它可以通过我们的 C# 代码调用。它将是紧凑的和更少的依赖。
【问题讨论】:
-
可能缺少一些根证书,导致加密 wss 连接的证书无效。
-
是否可以跳过证书验证?
标签: c# azure websocket .net-core azure-iot-hub