【问题标题】:Bot stopped responding with self signed certificateBot 停止响应自签名证书
【发布时间】:2018-07-25 04:03:49
【问题描述】:

我使用 pyTelegrambotAPI、cherrypy 作为网络服务器、更新方法 webhook、自签名证书,今晚在工作六个月后没有任何问题,我的 2 个机器人停止响应。

当我使用命令时:

https://api.telegram.org/botMYTOKEN/getwebhookinfo 结果是

{"ok":true,"result":{"url":"https://MY.IP.ADRESS/MYTOKEN/","has_custom_certificate":false,"pending_update_count":16853,"last_error_date":1518617645,"last_error_message":"SSL 错误{337047686,错误:1416F086:SSL 例程:tls_process_server_certificate:certificate verify failed}","max_connections":40}}

所以说SSL的错误,然后我尝试制作一个新的自签名证书并使用命令

curl -F "url=https://MY.IP.ADRESS" -F "certificate=@C:\Users\007\Desktop\bin\webhook_cert5.pem" https://api.telegram.org/botMYTOKEN/setWebhook

答案是

{"ok":true,"result":true,"description":"Webhook 已设置"}

但 10 秒后,其证书验证失败。电报块是自签名证书吗?还是我做错了什么?

【问题讨论】:

  • 我想当我在自签名证书 Telegram 的完整路径之前使用 @ 符号从 curl 设置 webhook 时,看到它并且一切正常,但是当我运行我的网络服务器 Telegram 思考我的证书来自某个 CA,无法验证它

标签: ssl telegram python-telegram-bot


【解决方案1】:

嗯,我找到了答案。

我在上面的评论中是对的,如果您 curl 请求返回 Webhook 已设置,并且当您启动机器人时,您会看到错误 certificate verify failed 您只需要 @ 符号位于您的网络服务器上的证书路径之前,例如 bot.set_webhook(url=config.WEBHOOK_URL_BASE + config.WEBHOOK_URL_PATH, certificate=open("@" + config.WEBHOOK_SSL_CERT, 'r'))(它是cherrypy 网络)。

【讨论】:

    猜你喜欢
    • 2017-11-16
    • 2021-04-11
    • 2016-02-29
    • 2021-08-10
    • 1970-01-01
    • 1970-01-01
    • 2017-12-10
    • 2020-08-16
    • 1970-01-01
    相关资源
    最近更新 更多