-
-
Notifications
You must be signed in to change notification settings - Fork 84
Description
Library/API/IoT binding
nanoFramework.WebServer
Visual Studio version
No response
.NET nanoFramework extension version
No response
Target name(s)
ESP32_S3_ALL
Firmware version
Latest
Device capabilities
No response
Description
When I'm using WebServer on port 80 with HTTP, everything works normally, but when I use the example itself that is in the repository (https://github.com/nanoframework/Samples/blob/main/samples/Webserver/WebServer.Sample/WebServer.Sample/Program.cs), I receive some errors.
I also tried generating new certificates and the problem persists.
A VERY IMPORTANT detail is that I receive the ECONNRESET message only after I start an MQTT connection with SSL using another certificate. If start without certificate and segure connection works.
How to reproduce
private const string _myWebServerCrt =
@"-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----";
private const string _myWebServerPrivateKey =
@"-----BEGIN RSA PRIVATE KEY-----
-----END RSA PRIVATE KEY-----";
X509Certificate _myWebServerCertificate509 = new X509Certificate2(_myWebServerCrt, _myWebServerPrivateKey, "1234");
nanoFramework.WebServer.WebServer webServer = new nanoFramework.WebServer.WebServer(443, HttpProtocol.Https, types)
{
HttpsCert = _myWebServerCertificate509,
SslProtocols = SslProtocols.Tls12 | SslProtocols.Tls13
};
webServer.Start()
The code used for MQTTS is:
string s_certificate =
@"-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----";
X509Certificate caCert = new(s_certificate);
MqttClient mqttClient = new("broker.emqx.io", 8883, true, caCert, null, MqttSslProtocols.TLSv1_2);
MqttReasonCode status = mqttClient.Connect(Core.Configuration.Configs.Dispositivo.Serial, "device", "123456");
When any webserver endpoint is called, the below error is displayed
++++ Exception System.Net.Sockets.SocketException - CLR_E_FAIL (5) ++++
++++ Message:
++++ System.Net.Security.SslNative::SecureServerInit [IP: 0000] ++++
++++ System.Net.Security.SslStream::Authenticate [IP: 0024] ++++
++++ System.Net.Security.SslStream::AuthenticateAsServer [IP: 0016] ++++
++++ System.Net.HttpListener::AcceptThreadFunc [IP: 009a] ++++
Expected behaviour
No response
Screenshots
Make it possible to receive HTTPS requests
Sample project or code
No response
Aditional information
No response