1

Some time ago I started creating my own telegram-bot. I've some simple code and set up a project via composer. I plan to use xampp as a Server-software. I've created a directory in the C:\xampp\htdocs directory and called it bot. Inside the directory there is my code, including the composer.json and vendor/ directory.

When I run the apache server and open http://localhost/bot/main.php (which is the main-document), I get the following error:

Output of http://localhost/bot/main.php:

Fatal error: Uncaught exception 'Telegram\Bot\Exceptions\TelegramSDKException' with message 'cURL error 60: SSL certificate problem: self signed certificate in certificate chain (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)' in C:\xampp\htdocs\bot\vendor\irazasyed\telegram-bot-sdk\src\HttpClients\GuzzleHttpClient.php:114 Stack trace: #0 C:\xampp\htdocs\bot\vendor\irazasyed\telegram-bot-sdk\src\TelegramClient.php(117): Telegram\Bot\HttpClients\GuzzleHttpClient->send('https://api.tel...', 'POST', Array, Array, 60, false, 10) #1 C:\xampp\htdocs\bot\vendor\irazasyed\telegram-bot-sdk\src\Api.php(1014): Telegram\Bot\TelegramClient->sendRequest(Object(Telegram\Bot\TelegramRequest)) #2 C:\xampp\htdocs\bot\vendor\irazasyed\telegram-bot-sdk\src\Api.php(958): Telegram\Bot\Api->sendRequest('POST', 'getMe', Array) #3 C:\xampp\htdocs\bot\vendor\irazasyed\telegram-bot-sdk\src\Api.php(269): Telegram\Bot\Api->post('getMe') #4 C:\xampp\htdocs\bot\main.php(20): Telegram\Bot\Api->getMe() #5 {main} thrown in C:\xampp\htdocs\bot\vendor\irazasyed\telegram-bot-sdk\src\HttpClients\GuzzleHttpClient.php on line 114

I don't know what exactly the problem is, it seems to be an issue with a self-signed certificate, but I don't get what is the explicit problem and how to fix it.

I hope you can help me with an answer here.

mnille
  • 1,328
  • 4
  • 16
  • 20
Tobias F.
  • 1,050
  • 1
  • 11
  • 23
  • 1
    Telegram bots work over SSL (`https`). You `localhost` definitely doesn't support it. – u_mulder Oct 18 '16 at 11:29
  • @u_mulder How do i tell xampp to use https then? – Tobias F. Oct 18 '16 at 11:32
  • read this : http://stackoverflow.com/questions/4221874/how-do-i-allow-https-for-apache-on-localhost – Karthi Oct 18 '16 at 11:36
  • @LifeTimeProgrammer This looks good, I'll try this solution. – Tobias F. Oct 18 '16 at 13:42
  • @LifeTimeProgrammer I've tried the solution you posted a link to, during completing the instructions there were no errors. But when I open https://localhost/bot/main.php I get an 404 Error, and when I open https://localhost/main.php (just without the subdirectory) I get the same error message as before. – Tobias F. Oct 22 '16 at 15:07
  • check your port bcz some other services may run. @TobiasF. – Karthi Oct 24 '16 at 04:17
  • @LifeTimeProgrammer I've cheked if any other service is using Port 80 or 443 using resmon.exe, but there is no other service/process which uses port 80 and/or 443. – Tobias F. Oct 25 '16 at 14:57
  • run some other php files and check it. its worked or not @TobiasF. – Karthi Oct 26 '16 at 04:22
  • I tried to run some other php files, everything went well and no errors occured. The reason why I got an 404 Error was I choosed the wrong directory in the httpdssl.conf, this is now fixed. @LifeTimeProgrammer – Tobias F. Oct 31 '16 at 06:37
  • :( okay keep going – Karthi Oct 31 '16 at 06:45
  • I asked my Instructor at work, he told me it's probably an clientside-issue, it seems my server isn't accepting the certificates provided/ used by Telegram, so I have to tell curl to accept all ssl certificates, no matter if they are trusted or not. Now I try to figure out where in the Code I have to modify something, I hope it works this time. – Tobias F. Nov 01 '16 at 10:41
  • Well, finally i decided to use the Google AppEngine instead, so i don't have to worry about untrusted certificates and so on. It's now running fine. @LifeTimeProgrammer – Tobias F. Nov 07 '16 at 13:02

2 Answers2

1

UPDATE:

I finally decided to switch to the GoogleAppEngine, so I don't have to worry about untrusted certificates and so on, now everything is working fine. But thanks for your help anyway (especially @LifeTimeProgrammer).

Tobias F.
  • 1,050
  • 1
  • 11
  • 23
0

go to the file \vendor\irazasyed\telegram-bot-sdk\src\HttpClients\GuzzleHttpClient.php Changing the setting

   public function __construct(Client $client = null)
{
 $this->client = $client ?: new Client();
}

on

    public function __construct(Client $client = null)
{
$this->client = $client ?: new Client(['verify' => false ]);
}
  • 1
    This is not particulary helpful almost 6 years after this problem appeared and I found a solution for myself. Just needlessly bumps this question up :) – Tobias F. Jul 18 '22 at 11:39
  • Please never edit vendor files because after any update or install your loose your changes ! – vinceAmstoutz Jul 19 '22 at 14:09