【问题标题】:Telegram Bot Webhook Not Verifying My SSL CertificateTelegram Bot Webhook 未验证我的 SSL 证书
【发布时间】:2018-07-20 02:42:33
【问题描述】:

我有一个带有可信 SSL 证书版本 3 的网站。我从 SSL 颁发者那里获得了 4 个文件,其中一个是放在服务器上的域证书。

为我尝试过的机器人设置 webhook:

  1. URL模式下的简单setWebhook方法:

    https://api.telegram.org/bot447278997:*******************************nZW0/setWebhook?url=https://example.com/webhookMethod
    
  2. setWebhook 使用卷曲。我已经上传了来自证书颁发者的 4 个文件中的每一个,以及一个包含所有 4 个随机顺序文件的文件。 (curl 命令将我的证书识别为自签名证书并返回 SSL(60) 错误,因此我必须在命令中添加一个 --insecure 字词以忽略证书的验证并发送它)。这是命令:

    curl --insecure -F "url=https://example.com/webhookMethod" -F "certificate=@cert.pem" https://api.telegram.org/bot447278997:****************************nZW0/setWebhook
    

以上方法都没有使我的 webhook 工作。调用getWebhookInfo方法,每次都报错:

{
  "ok":true,
  "result":{
    "url":"https://example.com/webhookMethod",
    "has_custom_certificate":true,
    "pending_update_count":7,
    "last_error_date":1518169667,
    "last_error_message":"Wrong response from the webhook: 302 Found",
    "max_connections":40
  }
}

在某些尝试中,has_custom_certificate 变成了 Falselast_error_message 更改为 not verified certificateSSL error 等。

此外,我已经使用具有 SSL 验证的 Postman 测试了我的 Web 服务,并且一切都已设置好并且可以正常工作。 我也知道 Telegram 不支持 SSL 版本 2 和 3,但支持自签名证书。现在我要向他们发送经过验证的第 3 版证书,它应该可以工作,对吧?

提前感谢任何帮助。

【问题讨论】:

  • 请正确格式化您的代码。
  • 错误提示您返回 302(而不是 200)。为什么你认为这是 SSL 问题?

标签: curl ssl-certificate telegram telegram-bot telegram-webhook


【解决方案1】:

这不是 ssl 问题。您应该在响应中返回 200 而不是 302。据我所知,302 表示重定向。不要在响应消息中重定向。

【讨论】:

    猜你喜欢
    • 2018-01-28
    • 2020-08-14
    • 2021-04-11
    • 2016-03-12
    • 1970-01-01
    • 1970-01-01
    • 2017-06-13
    • 2019-03-29
    • 2017-12-16
    相关资源
    最近更新 更多