mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-15 00:15:15 +08:00
Add support for dotnet 10 (#2229)
* Add dotnet10 as target framework and fix breaking changes * Fix tests * Fix tests for CI * Fix typo
This commit is contained in:
@@ -202,9 +202,14 @@ public sealed class MqttTcpServerListener : IDisposable
|
||||
|
||||
clientCertificate = sslStream.RemoteCertificate as X509Certificate2;
|
||||
|
||||
// TODO: Check why this export is needed. Is there something else in the RemoteCertificate as a X509Certificate2???
|
||||
if (clientCertificate == null && sslStream.RemoteCertificate != null)
|
||||
{
|
||||
#if NET10_0_OR_GREATER
|
||||
clientCertificate = X509CertificateLoader.LoadCertificate(sslStream.RemoteCertificate.Export(X509ContentType.Cert));
|
||||
#else
|
||||
clientCertificate = new X509Certificate2(sslStream.RemoteCertificate.Export(X509ContentType.Cert));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<DebugType>Full</DebugType>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
|
||||
<OutputType>Exe</OutputType>
|
||||
<IsPackable>false</IsPackable>
|
||||
<LangVersion>default</LangVersion>
|
||||
|
||||
@@ -122,10 +122,12 @@ public sealed class HotSwapCerts_Tests
|
||||
certRequest.CertificateExtensions.Add(sanBuilder.Build());
|
||||
|
||||
using var certificate = certRequest.CreateSelfSigned(DateTimeOffset.Now.AddMinutes(-10), DateTimeOffset.Now.AddMinutes(10));
|
||||
#pragma warning disable SYSLIB0057
|
||||
var pfxCertificate = new X509Certificate2(
|
||||
certificate.Export(X509ContentType.Pfx),
|
||||
(string)null,
|
||||
X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable);
|
||||
#pragma warning restore SYSLIB0057
|
||||
|
||||
return pfxCertificate;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#if DEBUG
|
||||
|
||||
using System.Globalization;
|
||||
using MQTTnet.Internal;
|
||||
using MQTTnet.Packets;
|
||||
using MQTTnet.Protocol;
|
||||
@@ -52,7 +53,7 @@ public sealed class Load_Tests : BaseTestClass
|
||||
|
||||
for (var j = 0; j < 1000; j++)
|
||||
{
|
||||
publishPacket.Topic = j.ToString();
|
||||
publishPacket.Topic = j.ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
await client.SendAsync(publishPacket, CancellationToken.None);
|
||||
}
|
||||
@@ -139,7 +140,7 @@ public sealed class Load_Tests : BaseTestClass
|
||||
|
||||
for (var j = 0; j < 1000; j++)
|
||||
{
|
||||
var message = applicationMessageBuilder.WithTopic(j.ToString()).Build();
|
||||
var message = applicationMessageBuilder.WithTopic(j.ToString(CultureInfo.InvariantCulture)).Build();
|
||||
|
||||
await client.PublishAsync(message);
|
||||
}
|
||||
|
||||
@@ -520,10 +520,11 @@ public sealed class SubscriptionTopicHashTests : IDisposable
|
||||
static byte[] GetBytes(ulong value)
|
||||
{
|
||||
var bytes = BitConverter.GetBytes(value);
|
||||
|
||||
// Ensure that highest byte comes first for comparison left to right
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
return bytes.Reverse().ToArray();
|
||||
bytes = bytes.AsEnumerable().Reverse().ToArray();
|
||||
}
|
||||
|
||||
return bytes;
|
||||
|
||||
@@ -31,10 +31,12 @@ public sealed class Tls_Tests : BaseTestClass
|
||||
certRequest.CertificateExtensions.Add(sanBuilder.Build());
|
||||
|
||||
using var certificate = certRequest.CreateSelfSigned(DateTimeOffset.Now.AddMinutes(-10), DateTimeOffset.Now.AddMinutes(10));
|
||||
#pragma warning disable SYSLIB0057
|
||||
var pfxCertificate = new X509Certificate2(
|
||||
certificate.Export(X509ContentType.Pfx),
|
||||
(string)null,
|
||||
X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable);
|
||||
#pragma warning restore SYSLIB0057
|
||||
|
||||
return pfxCertificate;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,17 @@ public class BlobCertificateProvider(byte[] blob) : ICertificateProvider
|
||||
|
||||
public X509Certificate2 GetCertificate()
|
||||
{
|
||||
#if NET10_0_OR_GREATER
|
||||
|
||||
if (string.IsNullOrEmpty(Password))
|
||||
{
|
||||
return X509CertificateLoader.LoadCertificate(Blob);
|
||||
}
|
||||
|
||||
return X509CertificateLoader.LoadPkcs12(Blob, Password);
|
||||
|
||||
#else
|
||||
|
||||
if (string.IsNullOrEmpty(Password))
|
||||
{
|
||||
// Use a different overload when no password is specified. Otherwise, the constructor will fail.
|
||||
@@ -21,5 +32,7 @@ public class BlobCertificateProvider(byte[] blob) : ICertificateProvider
|
||||
}
|
||||
|
||||
return new X509Certificate2(Blob, Password);
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -7,3 +7,4 @@
|
||||
* Marked all projects as AOT compatible
|
||||
* Restored the strong name of the nugets
|
||||
* Embedded license file in all nugets (#2197, thanks to @JensNordenbro)
|
||||
* Added support for dotnet10
|
||||
|
||||
Reference in New Issue
Block a user