Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

WIP: HttpsConnectionMiddleware #2849

Closed
wants to merge 2 commits into from

Conversation

davidfowl
Copy link
Member

@davidfowl davidfowl commented Aug 24, 2018

Porting the HttpsConnectionAdapter to HttpConnectionMiddleware. There are a few things that are interesting:

  • The HttpProtocol assumes that closing the output will close the input. I don't love that assumption but I preserved it here.
  • Creating pipes is messy when you need to flow settings around (for back pressure and scheduling). It would be better if we just had a custom pipe implementation that decorates the SSLStream.

@davidfowl davidfowl requested a review from halter73 August 24, 2018 07:10
certificateRequired = true;
}

using (var cancellationTokeSource = new CancellationTokenSource(_options.HandshakeTimeout))
Copy link
Member Author

Choose a reason for hiding this comment

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

This is no longer using IConnectionTimeout since it's added only added in HttpConnection.ProcessRequestAsync

// Set the list of protocols from listen options
httpsOptions.HttpProtocols = listenOptions.Protocols;
listenOptions.ConnectionAdapters.Add(new HttpsConnectionAdapter(httpsOptions, loggerFactory));
httpsOptions.MaxInputBufferSize = listenOptions.KestrelServerOptions?.Limits.MaxRequestBufferSize;
Copy link
Member Author

@davidfowl davidfowl Aug 24, 2018

Choose a reason for hiding this comment

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

This isn't great but it was the only way I could think of flowing the limits

@davidfowl davidfowl force-pushed the davidfowl/https-middleware branch from 6cc9b8d to 0c2fdaa Compare August 29, 2018 08:11
@davidfowl
Copy link
Member Author

@dotnet-bot test OSX 10.12 Release Build

@davidfowl davidfowl force-pushed the davidfowl/https-middleware branch from 0c2fdaa to 81edae2 Compare August 30, 2018 18:00

namespace Microsoft.AspNetCore.Server.Kestrel.Https.Internal
{
public class HttpsConnectionMiddleware
Copy link
Contributor

Choose a reason for hiding this comment

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

hi @davidfowl can I use this middleware to get tls support for the connection abstraction based mqtt handler I created?
(does this work with tcp or is http(s) required)

https://github.com/chkr1011/MQTTnet/blob/master/Source/MQTTnet.AspnetCore/MqttConnectionHandler.cs

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes the idea is to have a TlsMiddleware that's separate from Kestrel that can be placed in front of any ConnectionHandler. This is the first go to do that within Kestrel itself to see what issues exist.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants