I'm creating an ASP.NET Core 1.1 MVC web site, with OpenID authentication to Azure AD. Authentication works fine locally on my dev machine. However, when I deploy it to the server, it throws an error after logging into the microsoft login redirect. I'be been researching online for about 2 days, and have found similar issues, but nothing exactly like this. My local dev box is windows 10, visual studio 2017. The server I am deploying to is Server 2008R2, with the .net core server hosting runtime installed.
Here are the errors:
ERROR 2017-07-27 10:38:05,667 [4 ] on.OpenIdConnect.OpenIdConnectMiddleware - Exception occurred while processing message.
Microsoft.IdentityModel.Tokens.SecurityTokenInvalidSignatureException: IDX10503: Signature validation failed.
ERROR 2017-07-27 10:38:05,680 [4 ] e.Diagnostics.ExceptionHandlerMiddleware - An unhandled exception has occurred: Invalid non-ASCII or control character in header: 0x000D
System.InvalidOperationException: Invalid non-ASCII or control character in header: 0x000D
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.FrameHeaders.ThrowInvalidHeaderCharacter(Char ch)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.FrameHeaders.ValidateHeaderCharacters(String headerCharacters)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.FrameHeaders.ValidateHeaderCharacters(StringValues headerValues)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.FrameResponseHeaders.SetValueFast(String key, StringValues value)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.FrameHeaders.Microsoft.AspNetCore.Http.IHeaderDictionary.set_Item(String key, StringValues value)
at Microsoft.AspNetCore.Http.Internal.DefaultHttpResponse.Redirect(String location, Boolean permanent)
at FastInfo.Web.Startup.Startup.OnAuthenticationFailed(FailureContext context) in C:\SourceCode\Fast\FastInfo\src\FastInfo.Web\Startup\Startup.cs:line 168
at Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler1.<HandleRemoteCallbackAsync>d__6.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.RemoteAuthenticationHandler
1.d__5.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__15.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.AuthenticationMiddleware1.<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.AuthenticationMiddleware1.<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.Session.SessionMiddleware.d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Session.SessionMiddleware.d__9.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.Diagnostics.ExceptionHandlerMiddleware.d__6.MoveNext()
I am possibly missing some module or extension for OpenID tokens to work on IIS 7.5?
token header:
{
"typ": "JWT",
"alg": "RS256",
"x5t": "VWVIc1WD1Tksbb301sasM5kOq5Q",
"kid": "VWVIc1WD1Tksbb301sasM5kOq5Q"
}
payload (edited):
{
"aud": "b0337ae2-2097-4dd3-be43-983fee4217bd",
"iss": "https://sts.windows.net/{i removed guid}/",
"iat": 1501263956,
"nbf": 1501263956,
"exp": 1501267856,
"aio": "Y2ZgYDD9/5YpiT9XXmCDXMn/EzzPGa3nMbxfudOgpnfDsZk7/QMA",
"amr": [
"pwd"
],
"c_hash": "02fpZ5B7FecFoRVdeJi6Qw",
"family_name": "mylastname",
"given_name": "Joe",
"ipaddr": "##.###.###.##",
"name": "Joe mylastname",
"nonce": "636368610551942171.ZTU5ZGZmZmQtZDgzNS00MTEyLWExZjAtNWI3MTA2NGJlN2RkYzY0OTdkZjctZTZkMy00OTk2LWIxNjgtZTlhMDkxNmY0MzFh",
"oid": "26945208-7b3f-45ed-9b40-f33b9d767071",
"platf": "3",
"roles": [
"Admin"
],
"sub": "y-sRfJAMdidDOedJeyr7kLhH8BCfkV_YCdyT1p2mOmk",
"tid": "{i removed guid}",
"unique_name": "[email protected]",
"upn": "[email protected]",
"ver": "1.0"
}
Thanks for any help, Joe
nonce
claim in the header. To verify the signature from that site, you can compose the value with-----BEGIN CERTIFICATE-----{x5c}-----END CERTIFICATE-----
. About value ofx5c
, you can refer the value fromhttps://login.microsoftonline.com/common/discovery/keys
by matchingkid
. Is the issue fixed? - Fei Xue - MSFT