aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

Forwarding client certificates in IIS Kestrel reverse proxy setup

Open DavidFlamme opened this issue 7 years ago • 6 comments

I want to implement a custom client certificate authentication, preferably by using a IAsyncAuthorizationFilter to translate the certificate to an identity.

Asp.Net Core with .NET Framework 4.7.2 is running on Kestrel behind an IIS reverse proxy like it is described here: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/?view=aspnetcore-2.2&tabs=windows#out-of-process-hosting-model

The lead I could find is the ForwardClientCertificate setting described here: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/index?view=aspnetcore-2.2#iis-options

How I understand it is, that one sends an http request with the MS-ASPNETCORE-CLIENTCERT header with the base64 encoded client certificate as value. The ASP.NET Core Module in IIS (and IIS Express) takes the header, translates it into a certificate and provides (forwards) it to Kestrel as a ClientCertificate. I'm not really sure if this expects a https connection between IIS and Kestrel to do that, but it also seems to complicate things a lot anyway.

So I couldn't get this to work and think I'm missing something here. If not my feature request would be to just forward the MS-ASPNETCORE-CLIENTCERT header to Kestrel and use ITlsConnectionFeature to resolve the certificate in the AuthorizationFilter.

Thanks in advance, Davud

DavidFlamme avatar Feb 27 '19 16:02 DavidFlamme

Send a client cert the normal way, as part of the TLS handshake. We use this mechanic only with IIS and Kestrel since the last hop is after TLS termination.

As an aside, for security reasons we block all headers with MS-ASPNETCORE-* sent directly to IIS

muratg avatar Feb 27 '19 19:02 muratg

So, the same principle can be applied to any reverse proxy, like nginx for example? Stuffing encoded cert into MS-ASPNETCORE-CLIENTCERT header and asp.net core will do the magic? Is this somewhere documented?

MihaMarkic avatar May 31 '19 15:05 MihaMarkic

@MihaMarkic The new client cert forwarding bits should cater for this.

dcarr42 avatar May 31 '19 16:05 dcarr42

@DAllanCarr Do you have a link about it?

MihaMarkic avatar May 31 '19 17:05 MihaMarkic

https://github.com/aspnet/AspNetCore/issues/10645#issuecomment-497368455

On Fri, 31 May 2019, 18:50 Miha Markič, [email protected] wrote:

@DAllanCarr https://github.com/DAllanCarr Do you have a link about it?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aspnet/AspNetCore/issues/7998?email_source=notifications&email_token=ADKSKTG4KW3ERTWX64PVQQLPYFQM5A5CNFSM4G2TX3FKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWV5RWI#issuecomment-497801433, or mute the thread https://github.com/notifications/unsubscribe-auth/ADKSKTHDXDS4LK6F3BVVEODPYFQM5ANCNFSM4G2TX3FA .

dcarr42 avatar May 31 '19 18:05 dcarr42

Thank you for contacting us. Due to a lack of activity on this discussion issue we're closing it in an effort to keep our backlog clean. If you believe there is a concern related to the ASP.NET Core framework, which hasn't been addressed yet, please file a new issue.

This issue will be locked after 30 more days of inactivity. If you still wish to discuss this subject after then, please create a new issue!

ghost avatar Nov 12 '20 08:11 ghost