Authorization error: Cookies was not authenticated. Failure message: Unprotect ticket failed

I have the following code:

services.AddAuthentication(sharedOptions =>
                {
                    sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                    sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                    sharedOptions.DefaultChallengeScheme = WsFederationDefaults.AuthenticationScheme;
                })
                .AddWsFederation(options =>
                {
                    options.Wtrealm = Configuration["wtrealm"];
                    options.MetadataAddress = Configuration["wsfed"];
                    options.RequireHttpsMetadata = false;
                    options.UseTokenLifetime = false;
                })
                .AddCookie(cookieOptions =>
                {
                    cookieOptions.Cookie.HttpOnly = true;
                    cookieOptions.Cookie.SecurePolicy = CookieSecurePolicy.Always;
                });

I have setup Relying party trust on ADFS, for my local environment (Visual Studio, Kestrel Server) and running also running locally as a docker container, the authentication and authorization works perfectly.

However, when deployed as a docker container running in OpenShift, the authentication and authorization fails to work correctly.

I get the following error:

Cookies was not authenticated.

When I attempt to login and it redirects back to the home page of the app (which does not require auth to view). In ADFS, it says there’s a login loop detected, it appears that application tries multiple times to acquire a token from ADFS (possibly fails to store the token it receives in the first place).

I acquired a valid token from ADFS and tried to curl the app on a url that requires auth (passing the cookie as Header) and I receive the following error:

Cookies was not authenticated. Failure message: Unprotect ticket failed

Can anyone please share some information on what I can do to fix this issue?

Source: StackOverflow