英文:
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 {"ok":true,"result":true,"description":"Webhook was set"}
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 "/C=RU/ST=Test/L=Test/O=Example Inc/CN=domain.EXAMPLE"
webhook set
_, err = bot.SetWebhook(tgbotapi.NewWebhookWithCert(fmt.Sprintf("https://%s/%s", hook, token), "bot.pem"))
and server
go http.ListenAndServeTLS("0.0.0.0:8443", "bot.pem", "bot.key", 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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论