CONFIDENTIAL COMMUNICATION
This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.
Hello All,We are starting to use keycloak at my organization and need kerberos SSO. We use Active Directory so we already have a lot of the infrastructure, but I am consistently getting the following error message when I try to authenticate using kerberos.You can see in the output that the token is coming through and it's a kerberos token, so I'm pretty sure the client device is configured correctly.Error Message:2024-05-23 14:45:19,213 TRACE [org.keycloak.federation.kerberos.impl.SPNEGOAuthenticator] (executor-thread-32) SPNEGO Login with token: YIIH9QYGKwYBBQUCoIIH6TCCB... (most of token removed)Debug is true storeKey true useTicketCache false useKeyTab true doNotPrompt true ticketCache is null isInitiator false KeyTab is /etc/keycloakdqa.keytab refreshKrb5Config is false principal isHTTP/keycloakd...@TEST.CO tryFirstPass is false useFirstPass is false storePass is false clearPass is falseprincipal is HTTP/keycloakd...@TEST.COWill use keytabCommit Succeeded2024-05-23 14:45:19,213 TRACE [org.keycloak.federation.kerberos.impl.SPNEGOAuthenticator] (executor-thread-32) Going to establish securitycontext2024-05-23 14:45:19,215 WARN [org.keycloak.federation.kerberos.impl.SPNEGOAuthenticator] (executor-thread-32) SPNEGO login failed: java.security.PrivilegedActionException: GSSException: Failure unspecified at GSS-API level (Mechanism level: Invalid argument (400) -Cannot find key of appropriate type to decrypt AP-REQ - AES256 CTS mode with HMAC SHA1-96)at java.base/java.security.AccessController.doPrivileged(AccessController.java:716)at java.base/javax.security.auth.Subject.doAs(Subject.java:439)at org.keycloak.federation.kerberos.impl.SPNEGOAuthenticator.authenticate(SPNEGOAuthenticator.java:69)at org.keycloak.storage.ldap.LDAPStorageProvider.authenticate(LDAPStorageProvider.java:757)at org.keycloak.storage.UserStorageManager.getUserByCredential(UserStorageManager.java:153)at org.keycloak.models.cache.infinispan.UserCacheSession.getUserByCredential(UserCacheSession.java:551)at org.keycloak.authentication.authenticators.browser.SpnegoAuthenticator.authenticate(SpnegoAuthenticator.java:88)at org.keycloak.authentication.DefaultAuthenticationFlow.processSingleFlowExecutionModel(DefaultAuthenticationFlow.java:445)at org.keycloak.authentication.DefaultAuthenticationFlow.processFlow(DefaultAuthenticationFlow.java:271)at org.keycloak.authentication.AuthenticationProcessor.authenticateOnly(AuthenticationProcessor.java:1028)at org.keycloak.authentication.AuthenticationProcessor.authenticate(AuthenticationProcessor.java:885)at org.keycloak.protocol.AuthorizationEndpointBase.handleBrowserAuthenticationRequest(AuthorizationEndpointBase.java:153)at org.keycloak.protocol.oidc.endpoints.AuthorizationEndpoint.buildAuthorizationCodeAuthorizationResponse(AuthorizationEndpoint.java:337)at org.keycloak.protocol.oidc.endpoints.AuthorizationEndpoint.process(AuthorizationEndpoint.java:202)at org.keycloak.protocol.oidc.endpoints.AuthorizationEndpoint.buildGet(AuthorizationEndpoint.java:113)at org.keycloak.protocol.oidc.endpoints.AuthorizationEndpoint$quarkusrestinvoker$buildGet_4b690b27439f19dd29733dc5fd4004f24de0adb6.invoke(Unknown Source)at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:141)at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:145)at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:576)at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)at java.base/java.lang.Thread.run(Thread.java:840)Caused by: GSSException: Failure unspecified at GSS-API level (Mechanism level: Invalid argument (400) - Cannot find key of appropriate type to decrypt AP-REQ - AES256 CTS mode with HMAC SHA1-96)at java.security.jgss/sun.security.jgss.krb5.Krb5Context.acceptSecContext(Krb5Context.java:864)at java.security.jgss/sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:361)at java.security.jgss/sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:303)at java.security.jgss/sun.security.jgss.spnego.SpNegoContext.GSS_acceptSecContext(SpNegoContext.java:911)at java.security.jgss/sun.security.jgss.spnego.SpNegoContext.acceptSecContext(SpNegoContext.java:558)at java.security.jgss/sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:361)at java.security.jgss/sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:303)at org.keycloak.federation.kerberos.impl.SPNEGOAuthenticator.establishContext(SPNEGOAuthenticator.java:168)at org.keycloak.federation.kerberos.impl.SPNEGOAuthenticator$AcceptSecContext.run(SPNEGOAuthenticator.java:131)at org.keycloak.federation.kerberos.impl.SPNEGOAuthenticator$AcceptSecContext.run(SPNEGOAuthenticator.java:121)at java.base/java.security.AccessController.doPrivileged(AccessController.java:712)... 25 moreCaused by: KrbException: Invalid argument (400) - Cannot find key of appropriate type to decrypt AP-REQ - AES256 CTS mode with HMAC SHA1-96at java.security.jgss/sun.security.krb5.KrbApReq.authenticate(KrbApReq.java:278)at java.security.jgss/sun.security.krb5.KrbApReq.<init>(KrbApReq.java:149)at java.security.jgss/sun.security.jgss.krb5.InitSecContextToken.<init>(InitSecContextToken.java:139)at java.security.jgss/sun.security.jgss.krb5.Krb5Context.acceptSecContext(Krb5Context.java:837)... 35 more[Krb5LoginModule]: Entering logout[Krb5LoginModule]: logged out Subject2024-05-23 14:45:19,215 TRACE [org.keycloak.storage.ldap.LDAPStorageProvider] (executor-thread-32) SPNEGO Handshake not successful2024-05-23 14:45:19,215 TRACE [org.keycloak.storage.UserStorageManager] (executor-thread-32) Did not authenticate user by provider 'LDAPStorageProvider - ldap' with the credential type 'kerberos'. Will try to fallback to other user storage providers2024-05-23 14:45:19,215 WARN [org.keycloak.authentication.authenticators.browser.SpnegoAuthenticator] (executor-thread-32) Received kerberos token, but there is no user storage provider that handles kerberos credentials.2024-05-23 14:45:19,215 DEBUG [org.keycloak.authentication.DefaultAuthenticationFlow] (executor-thread-32) authenticator ATTEMPTED: auth-spnegoSetup Information:I mostly followed this guide: Server Administration Guide (keycloak.org)Note: I switched out the actual domain with a fake oneDockerFile:RUN echo "Installing and copying libraries..."# Install packages to ubi micro buildRUN mkdir -p /mnt/rootfsRUN dnf install --installroot /mnt/rootfs krb5-workstation krb5-libs vim procps iputils --releasever 9 --setopt install_weak_deps=false --nodocs -y && \dnf --installroot /mnt/rootfs clean all && \rpm --root /mnt/rootfs -e --nodeps setupRUN echo "Building Keycloak..."WORKDIR /opt/keycloak# Enable health and metrics supportENV KC_HEALTH_ENABLED=trueENV KC_METRICS_ENABLED=trueRUN /opt/keycloak/bin/kc.sh buildCOPY --from=ubi-micro-build /mnt/rootfs /COPY --from=builder /opt/keycloak/ /opt/keycloak/# switch to root user and give keycloak permissions on /var/log/USER rootRUN chown -R keycloak /var/log/USER keycloakENTRYPOINT ["/opt/keycloak/bin/kc.sh"]krb5.conf:includedir /etc/krb5.conf.d/[logging]default = FILE:/var/log/krb5libs.logkdc = FILE:/var/log/krb5kdc.logadmin_server = FILE:/var/log/kadmind.log[libdefaults]default_realm = TEST.COdns_lookup_realm = falseticket_lifetime = 24hrenew_lifetime = 7dforwardable = trueallow_weak_crypto = truerdns = false[realms]:qTEST.CO = {kdc = sv1.test.coadmin_server = sv1.test.co}[domain_realm][appdefaults]forwardable = trueAD User settings (service user):username: keycloakdqaUser UPN Login: HTTP/keycloakd...@TEST.COalso made sure to check the following two options:keytab generated using:ktpass -princ HTTP/keycloakd...@TEST.CO -mapUser keycl...@TEST.CO -pass <password> -crypto AES256-SHA1 -ptype KRB5_NT_PRINCIPAL -kvno 0 -out C:\Users\Public\Documents\keycloakdqa.keytaband then transferred to the linux server running the container and passed into the containerkeycloak configuration:Testing Kerberos/keytab/krb5:Going on the docker container withdocker exec -it keycloak bashI can run:kinit -fV -t /etc/keycloakdqa.keytab HTTP/keycloakdev.test.cokeytab specified, forcing -k
Using default cache: /tmp/krb5cc_1000
Using principal: HTTP/keycloakd...@TEST.CO
Using keytab: /etc/keycloakdqa.keytab
Authenticated to Kerberos v5klist
Valid starting Expires Service principal
05/23/2024 17:05:57 05/24/2024 03:05:57 krbtgt/TES...@TEST.CO
renew until 05/30/2024 17:05:57kvno HTTP/keycloakd...@TEST.COI also confirmed that matches AD's kvnoAny and all suggestions will be appreciated at this point. Have tried a lot of different keytabs, different accounts, tweaking configuration and so on and consistently get the same error.--Elliot JenksDevOps Engineer