Telegram bot api bad record mac(电报机器人API坏记录mac)

huangapple go评论76阅读模式
英文:

Telegram bot api bad record mac

问题

近三个月前,我的机器人出现了以下错误:

2021/07/23 17:34:39 在 SomeBot 账户上进行了授权

2021/07/23 17:34:39 {"ok":true,"result":true,"description":"Webhook was set"}

2021/07/23 17:35:28 来自 91.108.6.64:33364 的 http: TLS 握手错误: 本地错误: tls: bad record MAC

2021/07/23 17:35:28 来自 91.108.6.64:33436 的 http: TLS 握手错误: 本地错误: tls: bad record MAC

2021/07/23 17:35:30 来自 91.108.6.64:33792 的 http: TLS 握手错误: 本地错误: tls: bad record MAC

2021/07/23 17:35:30 来自 91.108.6.64:33828 的 http: TLS 握手错误: 本地错误: tls: bad record MAC

我认为这是旧证书错误,并根据 Telegram 文档的示例生成了新证书:
<https://core.telegram.org/bots/self-signed>

openssl req -newkey rsa:2048 -sha256 -nodes -keyout bot.key -x509 -days 365 -out bot.pem -subj "/C=RU/ST=Test/L=Test/O=Example Inc/CN=domain.EXAMPLE"

设置 webhook:

_, err = bot.SetWebhook(tgbotapi.NewWebhookWithCert(fmt.Sprintf("https://%s/%s", hook, token), "bot.pem"))

以及服务器:

go http.ListenAndServeTLS("0.0.0.0:8443", "bot.pem", "bot.key", nil)

但错误没有修复,日志仍然相同,请问如何解决这个问题?

英文:

Nearly three month ago my bot was broke with error like this

2021/07/23 17:34:39 Authorized on account SomeBot

2021/07/23 17:34:39 {&quot;ok&quot;:true,&quot;result&quot;:true,&quot;description&quot;:&quot;Webhook was set&quot;}

2021/07/23 17:35:28 http: TLS handshake error from 91.108.6.64:33364: local error: tls: bad record MAC

2021/07/23 17:35:28 http: TLS handshake error from 91.108.6.64:33436: local error: tls: bad record MAC

2021/07/23 17:35:30 http: TLS handshake error from 91.108.6.64:33792: local error: tls: bad record MAC

2021/07/23 17:35:30 http: TLS handshake error from 91.108.6.64:33828: local error: tls: bad record MAC

I think it old certificate error and generate new from tg documentation example
<https://core.telegram.org/bots/self-signed>

openssl req -newkey rsa:2048 -sha256 -nodes -keyout bot.key -x509 -days 365 -out bot.pem -subj &quot;/C=RU/ST=Test/L=Test/O=Example Inc/CN=domain.EXAMPLE&quot;

webhook set

_, err = bot.SetWebhook(tgbotapi.NewWebhookWithCert(fmt.Sprintf(&quot;https://%s/%s&quot;, hook, token), &quot;bot.pem&quot;))

and server

go http.ListenAndServeTLS(&quot;0.0.0.0:8443&quot;, &quot;bot.pem&quot;, &quot;bot.key&quot;, nil)

but error not fixed, logs are same, how to fix this?

答案1

得分: 1

我遇到了这样的情况,当改变 Webhook 的域名时。我为新域名重新生成了 .crt、.csr 和 .key 文件(为新域名更改了 CN),现在它又可以正常工作了。

英文:

I met such situation, when changed domain name for webhook.
I regenerated .crt, .csr and .key for new domain (CN changed for new domain) and it works again.

huangapple
  • 本文由 发表于 2021年7月24日 02:44:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/68503822.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定