Answer the question
In order to leave comments, you need to log in
How to remove SSL verification for cURL in viber-bot-php?
I'm trying to work with https://github.com/Bogdaan/viber-bot-php to organize a viber channel. Faced with the fact that the library does not work on all servers. Some have issues with the SSL certificate.
I googled two solutions: installing a certificate and adding it to php.ini (this path is closed for me) and removing the certificate check altogether, in the release method from \vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php
. The second option does not work for me, when adding
curl_setopt($resource, CURLOPT_SSL_VERIFYHOST, null);
curl_setopt($resource, CURLOPT_SSL_VERIFYPEER, null);
Exception exception 'GuzzleHttp\Exception\RequestException' with message 'cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)' in C:\inetpub\wwwroot\xxxxxxxxx.ru\test\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:190
Stack trace:
#0 C:\inetpub\wwwroot\xxxxxxxxx.ru\test\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(153): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array)
#1 C:\inetpub\wwwroot\xxxxxxxxx.ru\test\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(106): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory))
#2 C:\inetpub\wwwroot\xxxxxxxxx.ru\test\vendor\guzzlehttp\guzzle\src\Handler\CurlHandler.php(43): GuzzleHttp\Handler\CurlFactory::finish(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory))
#3 C:\inetpub\wwwroot\xxxxxxxxx.ru\test\vendor\guzzlehttp\guzzle\src\Handler\Proxy.php(28): GuzzleHttp\Handler\CurlHandler->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#4 C:\inetpub\wwwroot\xxxxxxxxx.ru\test\vendor\guzzlehttp\guzzle\src\Handler\Proxy.php(51): GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler\{closure}(Object(GuzzleHttp\Psr7\Request), Array)
#5 C:\inetpub\wwwroot\xxxxxxxxx.ru\test\vendor\guzzlehttp\guzzle\src\PrepareBodyMiddleware.php(66): GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler\{closure}(Object(GuzzleHttp\Psr7\Request), Array)
#6 C:\inetpub\wwwroot\xxxxxxxxx.ru\test\vendor\guzzlehttp\guzzle\src\Middleware.php(30): GuzzleHttp\PrepareBodyMiddleware->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#7 C:\inetpub\wwwroot\xxxxxxxxx.ru\test\vendor\guzzlehttp\guzzle\src\RedirectMiddleware.php(70): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Request), Array)
#8 C:\inetpub\wwwroot\xxxxxxxxx.ru\test\vendor\guzzlehttp\guzzle\src\Middleware.php(60): GuzzleHttp\RedirectMiddleware->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#9 C:\inetpub\wwwroot\xxxxxxxxx.ru\test\vendor\guzzlehttp\guzzle\src\HandlerStack.php(67): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Request), Array)
#10 C:\inetpub\wwwroot\xxxxxxxxx.ru\test\vendor\guzzlehttp\guzzle\src\Client.php(277): GuzzleHttp\HandlerStack->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#11 C:\inetpub\wwwroot\xxxxxxxxx.ru\test\vendor\guzzlehttp\guzzle\src\Client.php(125): GuzzleHttp\Client->transfer(Object(GuzzleHttp\Psr7\Request), Array)
#12 C:\inetpub\wwwroot\xxxxxxxxx.ru\test\vendor\guzzlehttp\guzzle\src\Client.php(131): GuzzleHttp\Client->requestAsync('POST', 'send_message', Array)
#13 C:\inetpub\wwwroot\xxxxxxxxx.ru\test\vendor\bogdaan\viber-bot-php\src\Client.php(88): GuzzleHttp\Client->request('POST', 'send_message', Array)
#14 C:\inetpub\wwwroot\xxxxxxxxx.ru\test\vendor\bogdaan\viber-bot-php\src\Client.php(176): Viber\Client->call('send_message', Array)
#15 C:\inetpub\wwwroot\xxxxxxxxx.ru\test\viber_bot\webhook.php(74): Viber\Client->sendMessage(Object(Viber\Api\Message\Text))
#16 [internal function]: {closure}(Object(Viber\Api\Event\Message))
#17 C:\inetpub\wwwroot\xxxxxxxxx.ru\test\vendor\bogdaan\viber-bot-php\src\Bot\Manager.php(83): call_user_func(Object(Closure), Object(Viber\Api\Event\Message))
#18 C:\inetpub\wwwroot\xxxxxxxxx.ru\test\vendor\bogdaan\viber-bot-php\src\Bot.php(228): Viber\Bot\Manager->runHandler(Object(Viber\Api\Event\Message))
#19 C:\inetpub\wwwroot\xxxxxxxxx.ru\test\viber_bot\webhook.php(76): Viber\Bot->run()
#20 {main}
Next exception 'Viber\Api\Exception\ApiException' with message 'cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)' in C:\inetpub\wwwroot\xxxxxxxxx.ru\test\vendor\bogdaan\viber-bot-php\src\Client.php:91
Stack trace:
#0 C:\inetpub\wwwroot\xxxxxxxxx.ru\test\vendor\bogdaan\viber-bot-php\src\Client.php(176): Viber\Client->call('send_message', Array)
#1 C:\inetpub\wwwroot\xxxxxxxxx.ru\test\viber_bot\webhook.php(74): Viber\Client->sendMessage(Object(Viber\Api\Message\Text))
#2 [internal function]: {closure}(Object(Viber\Api\Event\Message))
#3 C:\inetpub\wwwroot\xxxxxxxxx.ru\test\vendor\bogdaan\viber-bot-php\src\Bot\Manager.php(83): call_user_func(Object(Closure), Object(Viber\Api\Event\Message))
#4 C:\inetpub\wwwroot\xxxxxxxxx.ru\test\vendor\bogdaan\viber-bot-php\src\Bot.php(228): Viber\Bot\Manager->runHandler(Object(Viber\Api\Event\Message))
#5 C:\inetpub\wwwroot\xxxxxxxxx.ru\test\viber_bot\webhook.php(76): Viber\Bot->run()
#6 {main}
Answer the question
In order to leave comments, you need to log in
use \GuzzleHttp\Client; // Тут подключаем пакет Guzzle
$cfg = array(
'defaults' => array(
'verify' => false, // This is profit :) Тут говорим, чтобы не проверял SSL
),
'http_errors' => false // ...
);
$client = new Client($cfg); // Передаём конфиг в Guzzle
// . . .тут допустим $client->get(URL);
run nginx on any VDS, OVZ and proxy all calls to your server!
An example of a combat config is here
server {
server_name YOUDOMAIN;
location / {
proxy_pass http://YOUIP;
proxy_set_header Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
listen 2443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/YOUDOMAIN/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/YOUDOMAIN/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
Perhaps the problem is in the hosting itself. Try contacting your hosting provider.
console screenshot please. So no one will tell you what the problem is, the errors are not visible
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question