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

Implement client certificate authentication #351

Closed
wants to merge 37 commits into from
Closed

Implement client certificate authentication #351

wants to merge 37 commits into from

Conversation

tmds
Copy link
Contributor

@tmds tmds commented Nov 10, 2015

Implement client certificate authentication (#332)

benaadams and others added 3 commits November 10, 2015 07:28
Task.Run eventually ends up being QueueUserWorkItem.
The returned task is ignored, so no added goodness.
Short running item.

Cut out the middleman
@dnfclas
Copy link

dnfclas commented Nov 10, 2015

Hi @tmds, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!

The agreement was validated by .NET Foundation and real humans are currently evaluating your PR.

TTYL, DNFBOT;

@@ -14,6 +14,8 @@
using Microsoft.AspNet.Server.Kestrel.Infrastructure;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Primitives;
using System.Security.Cryptography.X509Certificates;
using Microsoft.AspNet.Http.Features.Internal;
Copy link
Member

Choose a reason for hiding this comment

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

Sort usings

@davidfowl
Copy link
Member

@tmds Take a look at the appveyor failure

@@ -21,7 +26,7 @@ public static IApplicationBuilder UseKestrelHttps(this IApplicationBuilder app,

var prevFilter = serverInfo.ConnectionFilter ?? new NoOpConnectionFilter();

serverInfo.ConnectionFilter = new HttpsConnectionFilter(cert, prevFilter);
serverInfo.ConnectionFilter = new HttpsConnectionFilter(cert, mode, prevFilter);
Copy link
Member

Choose a reason for hiding this comment

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

HttpsConnectionFilter really should have an Options class like we do with most middleware.

Copy link
Member

Choose a reason for hiding this comment

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

@Tratcher
Copy link
Member

I think we need to make the IConnectionFilter abstraction more powerful so all of the client cert work can happen in the https package through extension points. @halter73

@tmds
Copy link
Contributor Author

tmds commented Nov 12, 2015

@davidfowl @Tratcher can you do another review?
Can you check these things in particular:

  • Should I remove this overload: UseKestrelHttps(this IApplicationBuilder app, X509Certificate2 cert)?
  • Are the 'names' okay?
  • Should the HttpsConnectionFilterOptions contain a pattern which makes specifying the server certificate mandatory (e.g. constructor argument)?
  • Is it okay to use TlsConnectionFeature from Microsoft.AspNet.Http.Features.Internal?

@@ -2,13 +2,18 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#if DNX451
Copy link
Member

Choose a reason for hiding this comment

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

This is looking good. Thanks for adding the HttpsConnectionFilterOptions.

Recently we enabled these HttpsConnectionFilterTests on CoreClr since SslStream is now available for that.

Can you rebase this PR on dev and verify that client certificates work with CoreClr? Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't work on CoreClr. The ssl validation callback gets a X509Certificate and the constructor X509Certificate2(X509Certificate) to convert it doesn't exist (yet).

I created an issue: https://github.com/dotnet/corefx/issues/4510

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tmds
Copy link
Contributor Author

tmds commented Nov 14, 2015

ok, rebasing did not work as expected...

@tmds
Copy link
Contributor Author

tmds commented Nov 14, 2015

I guess I did something wrong...
How can I make this show only the changes that are part of the pull request? And not those that I got by rebasing on dev?
What should I have done to rebase to not get in this situation?

@shahid-pk
Copy link

@tmnds do this
git checkout client_certificate
git rebase HEAD~37 -i

you will get a prompt squash all 36 comments only leave the one that you want and then resolve merge conflicts if their are any, and you are ready for the last step ... Note: if origin refers to your kestrel fork otherwise replace origin accordingly.

git push origin client_certificate --force

@tmds
Copy link
Contributor Author

tmds commented Nov 14, 2015

I made another pull request to replace this one #385

@shahid-pk thanks for your suggestion. I was unsure how to apply it. Executing the rebase command gave me a list of all commits. About half of these commits were part of the pull request, the other half came from 'rebasing'. It isn't clear to me what I should should select for those type of commits: pick, squash, .... I've read on stackoverflow I should have done a 'force push' to avoid combining the two histories.

@tmds tmds closed this Nov 14, 2015
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.

8 participants