0

I am using telegram.php to connect my bot. When I use sendmessage all of thing is ok in my logs but I do not receive anything from the bot.

When I check my log there is a problem like this:

ok:         False
curl_error_code:        51
curl_error:     SSL: no alternative certificate subject name matches target host name 'api.telegram.org'

I donit know what to do to fix it.

Martin Evans
  • 45,791
  • 17
  • 81
  • 97

2 Answers2

0

I don't know this telegram bot, but I see that it uses GuzzleHttp. During the initialization it doesn't accept any configuration Request::initialize()

public static function initialize(Telegram $telegram)
{
    if (!($telegram instanceof Telegram)) {
        throw new TelegramException('Invalid Telegram pointer!');
    }
    self::$telegram = $telegram;
    self::setClient(new Client(['base_uri' => self::$api_base_uri]));
}

you should check its documentation. I see that there are a lot of setters which makes you able to overwrite the default settings.

What you need is to set the the \GuzzleHttp\RequestOptions::VERIFY to false in the client config:

$this->client = new \GuzzleHttp\Client([
    'base_uri'                          => 'someAccessPoint',
    \GuzzleHttp\RequestOptions::HEADERS => [
        'User-Agent' => 'some-special-agent',
    ],
    'defaults'                          => [
        \GuzzleHttp\RequestOptions::CONNECT_TIMEOUT => 5,
        \GuzzleHttp\RequestOptions::ALLOW_REDIRECTS => true,
    ],
    \GuzzleHttp\RequestOptions::VERIFY  => false,
]);
Zoltán Süle
  • 1,482
  • 19
  • 26
0

For fix this problem copy this Url to browser and set webhook:

https://api.telegram.org/botTOKEN/setWebhook?url=https://yourwebsite.com

Solution 2 of The Error Let’s follow these simple steps:

Download this bundle of root certificates: https://curl.haxx.se/ca/cacert.pem Put in any location of your server. Open php.ini and add this line:

curl.cainfo = "[the_location]\cacert.pem"

Restart your webserver. That’s it.

Max
  • 99
  • 1
  • 4