Skip to content

Commit

Permalink
Merge pull request Azure#616 from nivalxer/fix_tls_net8
Browse files Browse the repository at this point in the history
Fix the issue of TLS handshake failure in .NET 8 environment.
  • Loading branch information
filipbitola authored Feb 6, 2024
2 parents 296166b + 392137e commit 5ccd19f
Show file tree
Hide file tree
Showing 18 changed files with 28 additions and 16 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 0.7.0.{build}
pull_requests:
do_not_increment_build_number: true
image: Visual Studio 2019
image: Visual Studio 2022
build_script:
- cmd: powershell .\build.ps1 -target PR
test: off
Expand Down
11 changes: 11 additions & 0 deletions src/DotNetty.Handlers/Tls/TlsHandler.MediationStream.Net.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ ValueTask<int> InLoopReadAsync(Memory<byte> buffer, CancellationToken cancellati
int read = this.ReadFromInput(buffer);
return new ValueTask<int>(read);
}
//.NET8 sslStream will return 0 sometimes.like:https://github.com/dotnet/wcf/issues/5205
if (buffer.IsEmpty)
{
return new ValueTask<int>(0);
}

Contract.Assert(this.sslOwnedMemory.IsEmpty);
// take note of buffer - we will pass bytes there once available
Expand All @@ -89,6 +94,12 @@ Task<int> OutOfLoopReadAsync(Memory<byte> buffer, CancellationToken cancellation
return Task.FromResult(read);
}

//.NET8 sslStream will return 0 sometimes.like:https://github.com/dotnet/wcf/issues/5205
if (buffer.IsEmpty)
{
return Task.FromResult(0);
}

Contract.Assert(this.sslOwnedMemory.IsEmpty);
// take note of buffer - we will pass bytes there once available
this.sslOwnedMemory = buffer;
Expand Down
2 changes: 1 addition & 1 deletion test/DotNetty.Buffers.Tests/DotNetty.Buffers.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0;net8.0</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AssemblyOriginatorKeyFile>../../DotNetty.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0;net8.0</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AssemblyOriginatorKeyFile>../../DotNetty.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0;net8.0</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AssemblyOriginatorKeyFile>../../DotNetty.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0;net8.0</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AssemblyOriginatorKeyFile>../../DotNetty.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0;net8.0</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Configurations>Debug;Release;Package</Configurations>
<Platforms>AnyCPU</Platforms>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0;net8.0</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AssemblyOriginatorKeyFile>../../DotNetty.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
Expand Down
2 changes: 1 addition & 1 deletion test/DotNetty.Codecs.Tests/DotNetty.Codecs.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0;net8.0</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AssemblyOriginatorKeyFile>../../DotNetty.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
Expand Down
2 changes: 1 addition & 1 deletion test/DotNetty.Common.Tests/DotNetty.Common.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0;net8.0</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AssemblyOriginatorKeyFile>../../DotNetty.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace DotNetty.Common.Tests.Utilities
using DotNetty.Tests.Common;
using Xunit;
using Xunit.Abstractions;
using ITimer = DotNetty.Common.Utilities.ITimer;

public class HashedWheelTimerTest : TestBase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0;net8.0</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AssemblyOriginatorKeyFile>../../DotNetty.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
Expand Down
2 changes: 1 addition & 1 deletion test/DotNetty.Microbench/DotNetty.Microbench.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0;net8.0</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AssemblyOriginatorKeyFile>../../DotNetty.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
Expand Down
2 changes: 1 addition & 1 deletion test/DotNetty.Tests.Common/DotNetty.Tests.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0;net8.0</TargetFrameworks>
<AssemblyOriginatorKeyFile>../../DotNetty.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<Configurations>Debug;Release;Package</Configurations>
Expand Down
2 changes: 1 addition & 1 deletion test/DotNetty.Tests.End2End/DotNetty.Tests.End2End.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0;net8.0</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AssemblyOriginatorKeyFile>../../DotNetty.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0;net8.0</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AssemblyOriginatorKeyFile>../../DotNetty.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</PropertyGroup>
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0;net8.0</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<ApplicationIcon />
<OutputTypeEx>library</OutputTypeEx>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net472;net5.0;net6.0;net8.0</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AssemblyOriginatorKeyFile>../../DotNetty.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
Expand Down

0 comments on commit 5ccd19f

Please sign in to comment.