-
Notifications
You must be signed in to change notification settings - Fork 600
Unable to obtain OpenID Configuration when running ver 1.1 of the OpenIdConnect/Kestrel libraries #1116
Comments
If I upgrade all AspNetCore libraries to 1.1, but leave Kestrel to version 1.0.2, I get the following: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.AspNetCore.DataProtection, Version=1.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) === Pre-bind state information ===
|
My Configure Method in Startup.cs;
|
Not directly related: |
It's the same issues as aspnet/DataProtection#187 we are thinking about a better solution but for now you can try adding a binding redirect from |
@Tratcher - This happened WHEN I updated everything to 1.1. I was just trying to see what would happen if I just left certain things on 1.1 and left Kestrel on 1.0.2. If I downgrade everything back to 1.0.2/1.0.1, it all works again. I also even tried getting rid of the JwtBearer all together and solely leaving OpenIDConnect. I get the same thing. |
@pakrym - I'll try that out and see if it works. |
@Tratcher - I went ahead and updated everything to the 1.1, set AutomaticChallenge to false for the Jwt and Cookie middleware and left it default for OpenIDconnect. After doing that, I needed to add in services.AddDataProtection() and services.AddWebEncoders, then the
Now I see:
If I change the AuthorizationPolicyBuilder to a blank constructor, I'm back to the original error from this issue. Is there something I'm missing? |
You're not using Identity, replace |
@Tratcher - So, I did notice that I set a custom AuthenticationScheme on the CookieAuthenticationOptions that was set to CookieAuthenticationDefaults.AuthenticationScheme. I changed the variable constructor parameter in the AuthorizationPolicyBuilder to be the same scheme. All that did was try to log me in to Forms Auth. I then decided to change it to OpenIdConnectDefaults.AuthenticationScheme and I'm back to the first error. |
Yup. I can access it directly in the browser. That's why I thought it was weird I was receiving this error. As I noted above, when everything is on version 1.0.2/1.0.1, it works flawlessly. It's only with the 1.1 libraries that I'm receiving this error. |
Follow up on aspnet/DataProtection#187 |
Hmm @Tratcher ..... So I was able to get the flow working with a combination of having everything on the 1.1 libraries, EXCEPT for Kestrel. The first time I tried this, I forgot that I also downgraded the IISIntegration package to 1.0.1 and I downgraded Kestrel to 1.0.2. With both the IISIntegration and Kestel package downgraded to 1.0.2 and 1.0.1 and everything else on 1.1, no flows occur and also no errors. This time, I simply just downgraded Kestrel to 1.0.2 while including the bindingRedirect that @pakrym suggested and adding in the services.AddWebEncoders() and services.AddDataProtection(); lines. Now I get redirected to my OpenID provider when I debug and no policies are needed. |
Actually.. The more I'm testing, the whole issue was with both Kestrel and IISIntegration packages downgraded from 1.1. I removed the AddWebEncoders and AddDataProtection methods and it still works. O_o |
I'm also having this problem and I'm not sure if and how the above discussions affects me since I'm not using
When upgrading Kestrel from 1.0.0 to 1.1.0 I get this error 100% of the time:
I've posted an issue about this in the Kestrel repo but since this post targets the same error I thought I would post here as well. aspnet/KestrelHttpServer#1352 |
Are any of you targeting .NET 4.6? We've had several issues with System.Net.Http on 4.6. Some of the dependency chains involved: |
@Tratcher - Yeah, the DiagnosticSource issue came up on my .NET 4.6.2 targeted project. Kestrel still blows up on .netcoreapp also. |
@snickler we've definitely seen a few issues around this but so far nothing we've seen is exactly the same as what you're running into. Would it be possible for you to upload a sample repro to GitHub so that we can debug it? |
@Eilon @Tratcher - I think my issue was a mix of different ones.
Now the big issue I've been seeing lately is one with the CallbackPath in the OpenIdConnectOptions. Before, I had it set to some random controller, but I want the call back to be the root web application path. Setting
The weird thing is that if I set |
That's not what CallbackPath is for. CallbackPath should point to a unique address and the middleware will handle those requests, it should not be pointed at an MVC controller or app root. I recommend keeping the default value "/signin-oidc". |
Gotcha. That's good to know. So ill have to make some /signin-oidc endpoint then? Or will it automatically deal with it? |
Also, what is the reason behind keeping the CallBackPath a relative path instead of allowing for external urls? |
The CallbackPath is the address where the middleware performs all it's auth work internally. I think the field you're actually looking for is the one used to specify the address to return to after auth is complete, correct? The default return address is the one that initially issued the challenge. If you want to override that you can do it in the challenge call. See https://github.com/aspnet/Templates/blob/dev/src/Rules/StarterWeb/OrganizationalAuth/Single/Common/Controllers/AccountController.cs#L19-L20 |
Yeah. I was essentially looking for modifying the redirecturi that gets passed to the IdP as a query string parameter when a challenge kicks off. |
I just ran into a similar error (see below), adding the Microsoft.ApplicationInsights.AspNetCore v2.0.0 package fixed it for me. I haven't dug into why this fixed it but hopefully this helps. FileLoadException: Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) |
@jjvainav - Are you using ApplicationInsights? Are you on v1.1 of all libraries? |
This appears to be an issue caused by the System.Net.Http 4.3.0 package and should be fixed in the System.Net.Http 4.3.1 package. Can you try referencing that directly? |
To those affected, please try adding a reference to this fixed NuGet package: https://www.nuget.org/packages/System.Net.Http/4.3.1 We believe that this will fix the issue you are seeing. Please let us know if you updated to that version and it doesn't work. If you're still seeing issues, please share your CSPROJ or project.json file so that we can investigate further. |
I honestly don't know what's changed as I haven't touched the original project I had the issues with, but upgrading Kestrel back to 1.1 doesn't give me the metadata errors anymore. The only thing I can think of is that I did update my VS2017 and installed .NET Core 1.0.3 at some point after I got this working. I don't know exactly what made it work again and I'm fully grasping at straws for trying to figure out how I blew this up in the beginning. It could have had to do with some weirdness in my applicationhost.config in regards to https endpoints or something. I don't know. One thing I DO know for sure is that the For reference, here's both my project.json and Startup.cs Project.json:
Startup.cs
|
That's the wrong value for CallbackPath, see my comments above. |
I know. I just happened go figure out the condition in which it works. I wondered what I changed to make that error message appear, and it only occurs when accessing the web root. It won't happen if you're accessing another relative url.
|
Awesome! That must mean I may have had a package that used an older version of the Http library at some point? Who knows. I think this can be closed if anyone else was able to resolve this problem by using the updated Http library. I know I’m not receiving this issue anymore, at least.
Thanks for all the help guys! I truly appreciate it (especially dealing with my 9,000 replies)
|
That sounds great, thanks everyone! |
When I'm running version 1.1 of the Microsoft.AspNetCore.Authentication.OpenIdConnect and Microsoft.AspNetCore.Kestrel libraries, I'm unable to kick off the auth flow when hitting a WebAPI endpoint that uses the Authorization attribute. I can continually reproduce this. Downgrading to 1.0.2/1.0.1 of the libraries and dependencies allows the redirection to the OpenID provider to occur, and the full auth flow to work.
Here's the error I'm receiving (with urls replaced):
Microsoft.AspNetCore.Server.Kestrel: Error: Connection id "0HL2EL99HNV9A": An unhandled exception was thrown by the application.
System.InvalidOperationException: IDX10803: Unable to obtain configuration from: 'https://myserver.domain/realm/.well-known/openid-configuration'. ---> System.IO.IOException: IDX10804: Unable to retrieve document from: 'https://myserver.domain/realm/.well-known/openid-configuration'. ---> System.IO.FileLoadException: Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at System.Net.Http.WinHttpHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClientHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpMessageInvoker.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.GetAsync(Uri requestUri, HttpCompletionOption completionOption, CancellationToken cancellationToken)
at Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.d__8.MoveNext()
--- End of inner exception stack trace ---
at Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfigurationRetriever.d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.IdentityModel.Protocols.ConfigurationManager
1.<GetConfigurationAsync>d__24.MoveNext() --- End of inner exception stack trace --- at Microsoft.IdentityModel.Protocols.ConfigurationManager
1.d__24.MoveNext()--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler.d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Authentication.AuthenticationHandler
1.<ChallengeAsync>d__72.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Authentication.AuthenticationHandler
1.d__72.MoveNext()--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Http.Authentication.Internal.DefaultAuthenticationManager.d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.ChallengeResult.d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__30.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__20.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Builder.RouterMiddleware.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware
1.<Invoke>d__18.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware
1.d__18.MoveNext()--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware
1.<Invoke>d__18.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware
1.d__18.MoveNext()--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware
1.<Invoke>d__18.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware
1.d__18.MoveNext()--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware.d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Hosting.Internal.RequestServicesContainerMiddleware.d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Frame`1.d__2.MoveNext()
Microsoft.AspNetCore.Hosting.Internal.WebHost: Information: Request finished in 748.4304ms 500
Microsoft.AspNetCore.Hosting.Internal.WebHost: Information: Request starting HTTP/1.1 GET http://localhost:21744/favicon.ico
Microsoft.AspNetCore.Hosting.Internal.WebHost: Information: Request finished in 11.2054ms 404
The program '[26032] chrome.exe: WebKit' has exited with code -1 (0xffffffff).
The program '[8268] iisexpress.exe: Program Trace' has exited with code 0 (0x0).
The program '[24528] WebAPIOAuth.exe' has exited with code 0 (0x0).
The program '[24528] WebAPIOAuth.exe: Program Trace' has exited with code 0 (0x0).
The program '[8268] iisexpress.exe' has exited with code 0 (0x0).
The text was updated successfully, but these errors were encountered: