Hello members,
I hope you’re all doing well. I’m currently working on an ASP.NET MVC application and have integrated Keycloak into my ASP.NET MVC application. When attempting to log in with Keycloak, I encounter the following error message:
IDX10500: Signature validation failed. Unable to resolve SecurityKeyIdentifier: 'SecurityKeyIdentifier
(
IsReadOnly = False,
Count = 1,
Clause[0] = System.IdentityModel.Tokens.NamedKeySecurityKeyIdentifierClause
)
',
token: '{"alg":"HS256","typ":"JWT","kid":"d6f986c1-1634-42c3-831c-def9eb705e3d"}.{"exp":1698658811,"iat":1698658511,"auth_time":1698658511,"jti":"a5529aaf-c1e8-4ce8-9fe1-87610e37c82f","iss":"http://localhost:8080/realms/Demo","aud":["TestSSO","account"],"sub":"7f1b6128-2d59-4c75-bf1a-18f978af79b0","typ":"Bearer","azp":"TestSSO","session_state":"64ce271d-3440-4b53-a711-23d00d41f032","acr":"1","allowed-origins":["http://localhost:64346/*"],"realm_access":{"roles":["offline_access","uma_authorization","default-roles-demo"]},"resource_access":{"account":{"roles":["manage-account","manage-account-links","view-profile"]}},"scope":"openid email testaudience profile","sid":"64ce271d-3440-4b53-a711-23d00d41f032","email_verified":false,"name":"Test User","preferred_username":"testuser1","given_name":"Test","family_name":"User","email":"mtech.navi@gmail.com"}'.
Here is my startup.cs
public class Startup
{
public void Configuration(IAppBuilder app)
{
// Name of the persistent authentication middleware for lookup
const string persistentAuthType = "KeycloakOwinAuthenticationSample_cookie_auth";
// --- Cookie Authentication Middleware - Persists user sessions between requests
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = persistentAuthType
});
app.SetDefaultSignInAsAuthenticationType(persistentAuthType); // Cookie is primary session store
// --- Keycloak Authentication Middleware - Connects to central Keycloak database
app.UseKeycloakAuthentication(new KeycloakAuthenticationOptions
{
// App-Specific Settings
ClientId = "TestSSO", // *Required*
ClientSecret = "ZVqHv3H5a4NrsHPdho8ki5pYKzEYKJg9", // If using public authentication, delete this line
VirtualDirectory = "", // Set this if you use a virtual directory when deploying to IIS
// Instance-Specific Settings
Realm = "Demo", // Don't change this unless told to do so
KeycloakUrl = "http://localhost:8080/", // Enter your Keycloak URL here
// Template-Specific Settings
SignInAsAuthenticationType = persistentAuthType, // Sets the above cookie with the Keycloak data
AuthenticationType = "KeycloakOwinAuthenticationSample_keycloak_auth", // Unique identifier for the auth middleware
DisableTokenSignatureValidation = false,
DisableAudienceValidation = false
});
}
}
.net framework - 4.5.2
I made several attempt to resolve this. But I could not fix the issue. I would greatly appreciate any guidance or assistance you can provide to help me overcome this authentication issue.
Thank you.