链接KAFKA异常:Authentication failed during authentication due to invalid credentials with SASL mechanism

这篇具有很好参考价值的文章主要介绍了链接KAFKA异常:Authentication failed during authentication due to invalid credentials with SASL mechanism。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

使用带kerberos 认证的Kafka客户端链接kafka 创建topic 出现如下异常:Authentication failed during authentication due to invalid credentials with SASL mechanism。kafka server 后台只有如下异常信息:

Failed authentication with /192.168.0.1 (Authentication failed during authentication due to invalid credentials with SASL mechanism GSSAPI) (org.apache.kafka.common.network.Selector)

开始排查问题原因:

通过查看Kafka源代码定位到错误大致发生在:

org.apache.kafka.common.security.authenticator.SaslServerAuthenticator 类的handleSaslToken 方法:
private void handleSaslToken(byte[] clientToken) throws IOException {
        if (!this.enableKafkaSaslAuthenticateHeaders) {
            byte[] response = this.saslServer.evaluateResponse(clientToken);
            if (this.reauthInfo.reauthenticating() && this.saslServer.isComplete()) {
                this.reauthInfo.ensurePrincipalUnchanged(this.principal());
            }

            if (response != null) {
                this.netOutBuffer = new NetworkSend(this.connectionId, ByteBuffer.wrap(response));
                this.flushNetOutBufferAndUpdateInterestOps();
            }
        } else {
            ByteBuffer requestBuffer = ByteBuffer.wrap(clientToken);
            RequestHeader header = RequestHeader.parse(requestBuffer);
            ApiKeys apiKey = header.apiKey();
            short version = header.apiVersion();
            RequestContext requestContext = new RequestContext(header, this.connectionId, this.clientAddress(), KafkaPrincipal.ANONYMOUS, this.listenerName, this.securityProtocol);
            RequestAndSize requestAndSize = requestContext.parseRequest(requestBuffer);
            if (apiKey != ApiKeys.SASL_AUTHENTICATE) {
                IllegalSaslStateException e = new IllegalSaslStateException("Unexpected Kafka request of type " + apiKey + " during SASL authentication.");
                this.buildResponseOnAuthenticateFailure(requestContext, requestAndSize.request.getErrorResponse(e));
                throw e;
            }

            if (!apiKey.isVersionSupported(version)) {
                throw new UnsupportedVersionException("Version " + version + " is not supported for apiKey " + apiKey);
            }

            if (!this.reauthInfo.connectedClientSupportsReauthentication) {
                this.reauthInfo.connectedClientSupportsReauthentication = version > 0;
            }

            SaslAuthenticateRequest saslAuthenticateRequest = (SaslAuthenticateRequest)requestAndSize.request;

            try {
                byte[] responseToken = this.saslServer.evaluateResponse(Utils.copyArray(saslAuthenticateRequest.data().authBytes()));
                if (this.reauthInfo.reauthenticating() && this.saslServer.isComplete()) {
                    this.reauthInfo.ensurePrincipalUnchanged(this.principal());
                }

                byte[] responseBytes = responseToken == null ? new byte[0] : responseToken;
                long sessionLifetimeMs = !this.saslServer.isComplete() ? 0L : this.reauthInfo.calcCompletionTimesAndReturnSessionLifetimeMs();
                this.sendKafkaResponse(requestContext, new SaslAuthenticateResponse((new SaslAuthenticateResponseData()).setErrorCode(Errors.NONE.code()).setAuthBytes(responseBytes).setSessionLifetimeMs(sessionLifetimeMs)));
            } catch (SaslAuthenticationException var13) {
                this.buildResponseOnAuthenticateFailure(requestContext, new SaslAuthenticateResponse((new SaslAuthenticateResponseData()).setErrorCode(Errors.SASL_AUTHENTICATION_FAILED.code()).setErrorMessage(var13.getMessage())));
                throw var13;
            } catch (SaslException var14) {
                KerberosError kerberosError = KerberosError.fromException(var14);
                if (kerberosError != null && kerberosError.retriable()) {
                    throw var14;
                }

                String errorMessage = "Authentication failed during " + this.reauthInfo.authenticationOrReauthenticationText() + " due to invalid credentials with SASL mechanism " + this.saslMechanism;
                this.sendKafkaResponse(requestContext, new SaslAuthenticateResponse((new SaslAuthenticateResponseData()).setErrorCode(Errors.SASL_AUTHENTICATION_FAILED.code()).setErrorMessage(errorMessage)));
                throw new SaslAuthenticationException(errorMessage, var14);
            }
        }

    }

大概是在  saslServer.evaluateResponse 的时候抛出了异常,可是看不到具体的异常信息。

接下来使用 Arthas,查看具体的异常信息,Arthas 的使用方法略过,大家可以直接在Arthas官网查看。

使用Arthas链接上Kafka进程后 使用 sm 命令查找 org.apache.kafka.common.security.authenticator.SaslServerAuthenticator 类 和  handleSaslToken 方法。

使用 watch 命令 来查看这个方法的参数 返回值 和异常信息:

watch org.apache.kafka.common.security.authenticator.SaslServerAuthenticator handleSaslToken {params,returnObj,throwExp} -e  -x 6 

终于看到了真正导致认证失败的异常信息:

 KrbException: Clock skew too great (37)

这个异常信息的原因就是时钟不同步,经排查原来是 Kafka集群的NTP服务挂了导致的,启动NTP服务,同步时钟,搞定。文章来源地址https://www.toymoban.com/news/detail-502721.html

到了这里,关于链接KAFKA异常:Authentication failed during authentication due to invalid credentials with SASL mechanism的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • git 报错 fatal: Authentication failed的解决

    git提交代码的时候,报错 remote: Support for password authentication was removed on August 13, 2021. remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication. fatal: Authentication faile 大概意思是说对密码

    2024年02月11日
    浏览(46)
  • 【已解决】Git下载私有仓库时报错Authentication failed

    用git下载partner提供的private repo时,提示需要输入username和password。但怎么输入都报Authentication failed 的错误。 报错log: remote: Support for password authentication was removed on August 13, 2021. remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-u

    2024年02月02日
    浏览(26)
  • fiddler-----Authentication.AuthenticationException 调用 SSPI 失败,请参见内部异常

    返回: System.Security.SecurityException Failed to negotiate HTTPS connection with server.fiddler.network.https HTTPS handshake to http:*********** failed. System.Security.Authentication.AuthenticationException 调用 SSPI 失败, 要求的函数不受支持n\\\" ‘n’ + \\\'Win32 (SChannel) Native Error Code: 0x80090302 思路1:找到浏览器的代理服

    2024年02月11日
    浏览(27)
  • Telnet SMTP协议关于“535 Error: authentication failed“解决思路

    计算机网络中应用层的SMTP(Simple Mail Transfer Protocol)协议可用来发送邮件,在Telnet使用SMTP登陆账号密码时出现“535 Error: authentication failed”问题。现记录解决步骤。 1. 确认在邮箱中已开启SMTP服务。 2.  按照扫码流程,获得 授权密码 (一定要保存好), 该授权密码是用于登录第

    2024年02月02日
    浏览(40)
  • workbench 链接mysql 报错 authentication plugin caching_sha2_password

    用workbench连接MySQL出现Authentication plugin ‘caching_sha2_password’ cannot be loaded的问题,如下图 原因 出现这个问题的原因是由于Navicat和MySQL的版本问题, mysql8 之前,加密规则是mysql_native_password; mysql8 之后,加密规则是caching_sha2_password。 解决方法一种是升级Navicat驱动,一种是My

    2024年02月11日
    浏览(35)
  • github 上传代码报错 fatal: Authentication failed for ‘xxxxxx‘

    问题 今天一时兴起创建了个 github 新仓库,首次上传本地代码时,遇到了一个报错。本来以为是账号密码的问题,搞了好几次,发现都没错的情况下还是上传不上去。目测判断是认证相关问题,具体报错信息如下: 解决 其实从报错信息就可以看得出来,github 的认证策略发生

    2024年02月05日
    浏览(37)
  • 【已解决】fatal: Authentication failed for ‘https://github.com/.../‘

    在 Linux 服务器上使用 git push 命令,输入用户名和密码之后,总会显示一个报错: 起初我认为可能是密码输错了,但重新试过很多次后依然不行 到网上查阅,才知道原来是 github 的问题… 长话短说:大概就是 github 现在不让使用 用户名+密码 的方式进行验证 ,解决起来也不难

    2024年01月18日
    浏览(39)
  • git权限问题解决方法Access denied fatal: Authentication failed

    git pull 代码 或者 git push 时,遇到 Access denied问题: $ git pull remote: HTTP Basic: Access denied fatal: Authentication failed for ‘http://gitlab.corp.xxxx.com/yyyy/xxxx.git/’ 直接登录gitlab没问题,但是本地免密提交有问题,直接解决方案: ① 查询用户信息 重点信息确认: 注意: user.name 和 user.ema

    2024年02月12日
    浏览(37)
  • 解决git fatal: Authentication failed for ‘https://github.com

    git clone 遇到的错误 remote: Support for password authentication was removed on August 13, 2021. remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication. fatal: Authentication failed for ‘https://github.com/Drif

    2024年02月03日
    浏览(38)
  • 解决 fatal: Authentication failed for ‘https://github.com/*/*.git/‘

    原因:github 的认证策略发生了改变,在  2021年8月13日  的时候, 用户名加密码 的认证方式被去掉了,换成了 个人令牌(Personal Access Token) 的校验方式。 官网解决方案:管理个人访问令牌 - GitHub 文档  填写生成令牌的目的,然后选择令牌的有效期,最后勾选令牌的作用范

    2024年02月07日
    浏览(37)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包