Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert TLS connection adapter to connection middleware #11109

Merged
merged 5 commits into from
Jun 20, 2019

Conversation

jkotalik
Copy link
Contributor

Handles part of #4623

Pretty much is a direct port of aspnet/KestrelHttpServer#2849 to 3.0. Honestly confused why we didn't merge it before, things overall looked good with it.

Follow up:

  • Implement SslDuplexPipe : Stream, IDuplexPipe to remove allocations of two pipes and the RawStream.
  • Any breaking changes to remove all adapters

Drafting to write some follow-up questions to make sure design wise everything looks good.

@jkotalik jkotalik requested review from halter73 and davidfowl June 11, 2019 20:28
@jkotalik jkotalik added this to the 3.0.0-preview7 milestone Jun 11, 2019
@jkotalik jkotalik marked this pull request as ready for review June 11, 2019 22:07
halter73
halter73 previously approved these changes Jun 11, 2019
Copy link
Member

@halter73 halter73 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good except I'd remove the cross-cancellation

@jkotalik
Copy link
Contributor Author

@aspnet/build thoughts?

  Results will be available from https://mc.dot.net/#/user/aspnetcore/pr~2Faspnet~2Faspnetcore/ci/20190611.42.1
  Sent Helix Job 6fb69598-c097-4168-87bc-5020cd2b7ee9
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error : ArgumentException: Provided Job List Uri is not accessible [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error :    at Microsoft.DotNet.Helix.Client.HelixApi.HandleFailedRequest(RestApiException ex) in /_/src/Microsoft.DotNet.Helix/Client/CSharp/HelixApi.cs:line 29 [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error :    at Microsoft.DotNet.Helix.Client.HelixApi.OnFailedRequest(RestApiException ex) in /_/src/Microsoft.DotNet.Helix/Client/CSharp/generated-code/HelixApi.cs:line 116 [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error :    at Microsoft.DotNet.Helix.Client.Job.<NewInternalAsync>d__10.MoveNext() in /_/src/Microsoft.DotNet.Helix/Client/CSharp/generated-code/Job.cs:line 273 [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error : --- End of stack trace from previous location where exception was thrown --- [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error :    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error :    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error :    at Microsoft.DotNet.Helix.Client.Job.<NewAsync>d__9.MoveNext() in /_/src/Microsoft.DotNet.Helix/Client/CSharp/generated-code/Job.cs:line 190 [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error : --- End of stack trace from previous location where exception was thrown --- [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error :    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error :    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error :    at Microsoft.DotNet.Helix.Client.HelixApi.<RetryAsync>d__69`1.MoveNext() [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error : --- End of stack trace from previous location where exception was thrown --- [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error :    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error :    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error :    at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error :    at Microsoft.DotNet.Helix.Client.JobDefinition.<SendAsync>d__81.MoveNext() in /_/src/Microsoft.DotNet.Helix/JobSender/JobDefinition.cs:line 225 [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error : --- End of stack trace from previous location where exception was thrown --- [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error :    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error :    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error :    at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error :    at Microsoft.DotNet.Helix.Sdk.SendHelixJob.<ExecuteCore>d__65.MoveNext() in /_/src/Microsoft.DotNet.Helix/Sdk/SendHelixJob.cs:line 234 [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error : --- End of stack trace from previous location where exception was thrown --- [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error :    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error :    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error :    at Microsoft.DotNet.Helix.Sdk.HelixTask.Execute() in /_/src/Microsoft.DotNet.Helix/Sdk/HelixTask.cs:line 45 [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error : RestApiException: The response contained an invalid status code 400 Bad Request [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error :  [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error : Body: {"Message":"Provided Job List Uri is not accessible"} [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error :  [F:\workspace\_work\1\s\eng\helix\helix.proj]
F:\workspace\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19302.2\tools\Microsoft.DotNet.Helix.Sdk.MonoQueue.targets(51,5): error :  [F:\workspace\_work\1\s\eng\helix\helix.proj]

@natemcmaster
Copy link
Contributor

natemcmaster commented Jun 12, 2019 via email

@davidfowl davidfowl force-pushed the jkotalik/connectionMiddleware branch from cc695ae to 90a4b81 Compare June 19, 2019 17:33
@davidfowl davidfowl requested a review from halter73 June 19, 2019 23:17
@davidfowl davidfowl dismissed halter73’s stale review June 19, 2019 23:18

The code has changed a bunch

@@ -69,33 +71,58 @@ public HttpsConnectionAdapter(HttpsConnectionAdapterOptions options, ILoggerFact
}

_options = options;
_logger = loggerFactory?.CreateLogger<HttpsConnectionAdapter>() ?? (ILogger)NullLogger.Instance;
_logger = loggerFactory?.CreateLogger<HttpsConnectionMiddleware>();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: newline

{
SslStream sslStream;
bool certificateRequired;
var feature = new Core.Internal.TlsConnectionFeature();
context.Features.Set<ITlsConnectionFeature>(feature);
context.Features.Set<ITlsHandshakeFeature>(feature);

// TODO: Handle the cases where this can be null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: remove TODO or do it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm aware there are TODO comments in Kestrel. That one was checked in five years ago when Kestrel was still a test server. I bet you could find a bunch more recent examples than that, but I don't really see the point. I'm glad you don't plan to just leave this there though.

minimumSegmentSize: memoryPoolFeature.MemoryPool.GetMinimumSegmentSize()
);

// TODO: eventually make SslDuplexStream : Stream, IDuplexPipe to avoid RawStream allocation and pipe allocations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This TODO on the other hand is fine. This seems like a fair bit of work.

@davidfowl
Copy link
Member

@davidfowl
Copy link
Member

/azp run AspNetCore-ci

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@aspnet-hello
Copy link

This comment was made automatically. If there is a problem contact [email protected].

I've triaged the above build. I've created/commented on the following issue(s)
https://github.com/aspnet/AspNetCore-Internal/issues/2410
https://github.com/aspnet/AspNetCore-Internal/issues/2623
https://github.com/aspnet/AspNetCore-Internal/issues/2415

@@ -215,64 +215,90 @@ private HttpConnectionContext CreateDerivedContext(IDuplexPipe transport)

private void StopProcessingNextRequest()
{
ProtocolSelectionState previousState;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need these changes?

Copy link
Contributor Author

@jkotalik jkotalik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approve, but this is my PR 😃

@jkotalik
Copy link
Contributor Author

I'm going to go ahead and merge this. I'm OOF friday so I'd like to be able to revert if something is failing due to this change.

@jkotalik jkotalik merged commit 689b052 into master Jun 20, 2019
@ghost ghost deleted the jkotalik/connectionMiddleware branch June 20, 2019 03:02
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants