@@ -37,6 +37,12 @@ | |||||
<dependency id="System.Net.WebSockets" version="4.3.0" /> | <dependency id="System.Net.WebSockets" version="4.3.0" /> | ||||
<dependency id="System.Net.WebSockets.Client" version="4.3.2" /> | <dependency id="System.Net.WebSockets.Client" version="4.3.2" /> | ||||
</group> | </group> | ||||
<group targetFramework="netcoreapp3.1"> | |||||
<dependency id="NETStandard.Library" version="2.0.0" /> | |||||
<dependency id="System.Net.Security" version="4.3.2" /> | |||||
<dependency id="System.Net.WebSockets" version="4.3.0" /> | |||||
<dependency id="System.Net.WebSockets.Client" version="4.3.2" /> | |||||
</group> | |||||
<group targetFramework="uap10.0"> | <group targetFramework="uap10.0"> | ||||
<dependency id="Microsoft.NETCore.UniversalWindowsPlatform" version="6.2.10" /> | <dependency id="Microsoft.NETCore.UniversalWindowsPlatform" version="6.2.10" /> | ||||
</group> | </group> | ||||
@@ -59,6 +65,9 @@ | |||||
<!-- .NET Standard 2.1 --> | <!-- .NET Standard 2.1 --> | ||||
<file src="..\Source\MQTTnet\bin\Release\netstandard2.1\MQTTnet.*" target="lib\netstandard2.1\"/> | <file src="..\Source\MQTTnet\bin\Release\netstandard2.1\MQTTnet.*" target="lib\netstandard2.1\"/> | ||||
<!-- .NET Standard 3.1 --> | |||||
<file src="..\Source\MQTTnet\bin\Release\netcoreapp3.1\MQTTnet.*" target="lib\netcoreapp3.1\"/> | |||||
<!-- Universal Windows --> | <!-- Universal Windows --> | ||||
<file src="..\Source\MQTTnet\bin\Release\uap10.0\MQTTnet.*" target="lib\uap10.0\"/> | <file src="..\Source\MQTTnet\bin\Release\uap10.0\MQTTnet.*" target="lib\uap10.0\"/> | ||||
@@ -29,6 +29,7 @@ vstest.console.exe ..\Tests\MQTTnet.AspNetCore.Tests\bin\Release\netcoreapp3.1\M | |||||
&$msbuild ..\Source\MQTTnet\MQTTnet.csproj /t:Build /p:Configuration="Release" /p:TargetFramework="netstandard1.3" /p:FileVersion=$assemblyVersion /p:AssemblyVersion=$assemblyVersion /verbosity:m /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=".\..\..\Build\codeSigningKey.pfx" | &$msbuild ..\Source\MQTTnet\MQTTnet.csproj /t:Build /p:Configuration="Release" /p:TargetFramework="netstandard1.3" /p:FileVersion=$assemblyVersion /p:AssemblyVersion=$assemblyVersion /verbosity:m /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=".\..\..\Build\codeSigningKey.pfx" | ||||
&$msbuild ..\Source\MQTTnet\MQTTnet.csproj /t:Build /p:Configuration="Release" /p:TargetFramework="netstandard2.0" /p:FileVersion=$assemblyVersion /p:AssemblyVersion=$assemblyVersion /verbosity:m /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=".\..\..\Build\codeSigningKey.pfx" | &$msbuild ..\Source\MQTTnet\MQTTnet.csproj /t:Build /p:Configuration="Release" /p:TargetFramework="netstandard2.0" /p:FileVersion=$assemblyVersion /p:AssemblyVersion=$assemblyVersion /verbosity:m /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=".\..\..\Build\codeSigningKey.pfx" | ||||
&$msbuild ..\Source\MQTTnet\MQTTnet.csproj /t:Build /p:Configuration="Release" /p:TargetFramework="netstandard2.1" /p:FileVersion=$assemblyVersion /p:AssemblyVersion=$assemblyVersion /verbosity:m /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=".\..\..\Build\codeSigningKey.pfx" | &$msbuild ..\Source\MQTTnet\MQTTnet.csproj /t:Build /p:Configuration="Release" /p:TargetFramework="netstandard2.1" /p:FileVersion=$assemblyVersion /p:AssemblyVersion=$assemblyVersion /verbosity:m /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=".\..\..\Build\codeSigningKey.pfx" | ||||
&$msbuild ..\Source\MQTTnet\MQTTnet.csproj /t:Build /p:Configuration="Release" /p:TargetFramework="netcoreapp3.1" /p:FileVersion=$assemblyVersion /p:AssemblyVersion=$assemblyVersion /verbosity:m /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=".\..\..\Build\codeSigningKey.pfx" | |||||
&$msbuild ..\Source\MQTTnet\MQTTnet.csproj /t:Build /p:Configuration="Release" /p:TargetFramework="uap10.0" /p:FileVersion=$assemblyVersion /p:AssemblyVersion=$assemblyVersion /verbosity:m /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=".\..\..\Build\codeSigningKey.pfx" | &$msbuild ..\Source\MQTTnet\MQTTnet.csproj /t:Build /p:Configuration="Release" /p:TargetFramework="uap10.0" /p:FileVersion=$assemblyVersion /p:AssemblyVersion=$assemblyVersion /verbosity:m /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=".\..\..\Build\codeSigningKey.pfx" | ||||
# Build the ASP.NET Core 2.0 extension | # Build the ASP.NET Core 2.0 extension | ||||
@@ -27,6 +27,7 @@ | |||||
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp3.1'"> | <ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp3.1'"> | ||||
<PackageReference Include="Microsoft.AspNetCore.Http.Connections" Version="1.1.0" /> | <PackageReference Include="Microsoft.AspNetCore.Http.Connections" Version="1.1.0" /> | ||||
<PackageReference Include="System.IO.Pipelines" Version="4.7.2" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
@@ -280,7 +280,9 @@ namespace MQTTnet.Client.Options | |||||
#pragma warning disable CS0618 // Type or member is obsolete | #pragma warning disable CS0618 // Type or member is obsolete | ||||
CertificateValidationCallback = _tlsParameters.CertificateValidationCallback, | CertificateValidationCallback = _tlsParameters.CertificateValidationCallback, | ||||
#pragma warning restore CS0618 // Type or member is obsolete | #pragma warning restore CS0618 // Type or member is obsolete | ||||
#if NETCOREAPP3_1 | |||||
ApplicationProtocols = _tlsParameters.ApplicationProtocols, | |||||
#endif | |||||
CertificateValidationHandler = _tlsParameters.CertificateValidationHandler, | CertificateValidationHandler = _tlsParameters.CertificateValidationHandler, | ||||
IgnoreCertificateChainErrors = _tlsParameters.IgnoreCertificateChainErrors, | IgnoreCertificateChainErrors = _tlsParameters.IgnoreCertificateChainErrors, | ||||
IgnoreCertificateRevocationErrors = _tlsParameters.IgnoreCertificateRevocationErrors | IgnoreCertificateRevocationErrors = _tlsParameters.IgnoreCertificateRevocationErrors | ||||
@@ -27,7 +27,11 @@ namespace MQTTnet.Client.Options | |||||
public IEnumerable<X509Certificate> Certificates { get; set; } | public IEnumerable<X509Certificate> Certificates { get; set; } | ||||
#endif | #endif | ||||
public bool AllowUntrustedCertificates { get; set; } | |||||
#if NETCOREAPP3_1 | |||||
public List<SslApplicationProtocol> ApplicationProtocols { get;set; } | |||||
#endif | |||||
public bool AllowUntrustedCertificates { get; set; } | |||||
public bool IgnoreCertificateChainErrors { get; set; } | public bool IgnoreCertificateChainErrors { get; set; } | ||||
@@ -22,6 +22,10 @@ namespace MQTTnet.Client.Options | |||||
public List<X509Certificate> Certificates { get; set; } | public List<X509Certificate> Certificates { get; set; } | ||||
#endif | #endif | ||||
#if NETCOREAPP3_1 | |||||
public List<SslApplicationProtocol> ApplicationProtocols {get;set;} | |||||
#endif | |||||
public SslProtocols SslProtocol { get; set; } = SslProtocols.Tls12; | public SslProtocols SslProtocol { get; set; } = SslProtocols.Tls12; | ||||
[Obsolete("This property will be removed soon. Use CertificateValidationHandler instead.")] | [Obsolete("This property will be removed soon. Use CertificateValidationHandler instead.")] | ||||
@@ -20,6 +20,8 @@ | |||||
return "netstandard2.1"; | return "netstandard2.1"; | ||||
#elif WINDOWS_UWP | #elif WINDOWS_UWP | ||||
return "uap10.0"; | return "uap10.0"; | ||||
#elif NETCOREAPP3_1 | |||||
return "netcoreapp3.1"; | |||||
#endif | #endif | ||||
} | } | ||||
} | } | ||||
@@ -81,7 +81,22 @@ namespace MQTTnet.Implementations | |||||
var sslStream = new SslStream(networkStream, false, InternalUserCertificateValidationCallback); | var sslStream = new SslStream(networkStream, false, InternalUserCertificateValidationCallback); | ||||
try | try | ||||
{ | { | ||||
await sslStream.AuthenticateAsClientAsync(_options.Server, LoadCertificates(), _options.TlsOptions.SslProtocol, !_options.TlsOptions.IgnoreCertificateRevocationErrors).ConfigureAwait(false); | |||||
#if NETCOREAPP3_1 | |||||
var sslOptions = new SslClientAuthenticationOptions | |||||
{ | |||||
ApplicationProtocols = _options.TlsOptions.ApplicationProtocols, | |||||
ClientCertificates = LoadCertificates(), | |||||
EnabledSslProtocols = _options.TlsOptions.SslProtocol, | |||||
CertificateRevocationCheckMode = _options.TlsOptions.IgnoreCertificateRevocationErrors ? X509RevocationMode.Online : X509RevocationMode.NoCheck, | |||||
TargetHost = _options.Server | |||||
}; | |||||
await sslStream.AuthenticateAsClientAsync(sslOptions, cancellationToken).ConfigureAwait(false); | |||||
#else | |||||
await sslStream.AuthenticateAsClientAsync(_options.Server, LoadCertificates(), _options.TlsOptions.SslProtocol, !_options.TlsOptions.IgnoreCertificateRevocationErrors).ConfigureAwait(false); | |||||
#endif | |||||
} | } | ||||
catch | catch | ||||
{ | { | ||||
@@ -1,7 +1,7 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | <Project Sdk="Microsoft.NET.Sdk"> | ||||
<PropertyGroup> | <PropertyGroup> | ||||
<TargetFrameworks>netstandard1.3;netstandard2.0;netstandard2.1</TargetFrameworks> | |||||
<TargetFrameworks>netstandard1.3;netstandard2.0;netstandard2.1;netcoreapp3.1</TargetFrameworks> | |||||
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net452;net461</TargetFrameworks> | <TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net452;net461</TargetFrameworks> | ||||
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' AND '$(MSBuildRuntimeType)' != 'Core' AND '$(SolutionName)' != 'MQTTnet.noUWP' ">$(TargetFrameworks);uap10.0</TargetFrameworks> | <TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' AND '$(MSBuildRuntimeType)' != 'Core' AND '$(SolutionName)' != 'MQTTnet.noUWP' ">$(TargetFrameworks);uap10.0</TargetFrameworks> | ||||
<AssemblyName>MQTTnet</AssemblyName> | <AssemblyName>MQTTnet</AssemblyName> | ||||