Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/254.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ubuntu php 7.2 Laravel cURL错误60:SSL证书问题:无法获取本地颁发者证书请参阅http://curl.haxx.se_Php_Laravel_Ssl Certificate - Fatal编程技术网

Ubuntu php 7.2 Laravel cURL错误60:SSL证书问题:无法获取本地颁发者证书请参阅http://curl.haxx.se

Ubuntu php 7.2 Laravel cURL错误60:SSL证书问题:无法获取本地颁发者证书请参阅http://curl.haxx.se,php,laravel,ssl-certificate,Php,Laravel,Ssl Certificate,我在Ubuntu上使用了Laravel和PHP7.2。我想从以下网站下载比特币价格: https://btczexplorer.blockhub.info/ext/getbalance/t1ZYiG4R4n5gTgUKZRgVpKPzG5FYQXpEqga 在服务器上,我收到错误: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/lib

我在Ubuntu上使用了Laravel和PHP7.2。我想从以下网站下载比特币价格:

https://btczexplorer.blockhub.info/ext/getbalance/t1ZYiG4R4n5gTgUKZRgVpKPzG5FYQXpEqga
在服务器上,我收到错误:

cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
我在互联网上发现我必须安装证书。所以我做了:

root@server-1456254-1:/etc/ssl/certs# sudo wget http://curl.haxx.se/ca/cacert.pem
root@server-1456254-1:/etc/php/7.2/apache2# nano php.ini
in php.ini:
openssl.cafile=/etc/ssl/certs/cacert.pem
root@server-1456254-1:/etc/php/7.2/apache2# /etc/init.d/apache2 restart
但错误仍然存在。怎么了

-- 上述btczexplorer的url在Laravel的php文件中调用:

public function blockNotify($blockId)
    {

        try {

            $response = Rate::getAddressApiBalance('t1ZYiG4R4n5gTgUKZRgVpKPzG5FYQXpEqga');


            return $response;

        }catch (\Exception $e) {
            return $e->getMessage() . ' stack trace: ' . $e->getTraceAsString();
        }

        return "end";
和费率文件:

public static function getAddressApiBalance($address)
    {
        try {
            $uri = "https://btczexplorer.blockhub.info/ext/getbalance/" . $address;

            $response = Http::get($uri);

            return $response;
        } catch (InvalidArgumentException $exception){
            return 3;
            Log::error($exception);
        } catch (Exception $e) {
            return $e->getMessage();
            Log::error($e);
        }

        return 0;
    }
在网站上我的证书有错误

为什么我使用本地或CA?我在互联网上找到了这个解决方案


使用文件\u获取\u内容时,我们出现了相同的错误:

cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) stack trace: #0 /var/www/html/bitpay/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(149): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array) #1 /var/www/html/bitpay/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(102): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory)) #2
结果相同:文件\u获取\u内容():SSL操作失败,代码为1。OpenSSL错误消息:错误:1416F086:SSL例程:tls_进程_服务器_证书:证书验证失败的堆栈跟踪:#0[内部函数]:Illumb\Foundation\Bootstrap\HandleExceptions->handleError(2,'file_get_conten…','/var/www/html/b…,43,Array)#1/var/www/html/bitpay/app/Http/Controllers/BlockApiController.php(43):file_get_contents(“…”)#2[内部函数]:App\Http\Controllers\BlockApiController->blockNotify('000000 51507a8ce…)#3/var/www/html/bitpay/vendor/laravel/framework/src/illumb/Routing/Controller.php(54):调用用户函数数组(数组,数组)#4/var/www/html/bitpay/vendor/laravel/framework/src/illumb/Routing/Routing/ControllerDispatcher.php(45):照亮\路由\控制器->调用动作('blockNotify',数组)#5


也许会有帮助 命令
var\u dump(openssl\u get\u cert\u locations())
显示:

 array(8) { ["default_cert_file"]=> string(21) "/usr/lib/ssl/cert.pem" ["default_cert_file_env"]=> string(13) "SSL_CERT_FILE" ["default_cert_dir"]=> string(18) "/usr/lib/ssl/certs" ["default_cert_dir_env"]=> string(12) "SSL_CERT_DIR" ["default_private_dir"]=> string(20) "/usr/lib/ssl/private" ["default_default_cert_area"]=> string(12) "/usr/lib/ssl" ["ini_cafile"]=> string(25) "/etc/ssl/certs/cacert.pem" ["ini_capath"]=> string(0) "" }
所以我在php.ini中更改了证书的路径:
openssl.cafile=/usr/lib/ssl/certs/cacert.pem
但没有结果


现在我已将代码更改为纯guzzle客户端:

$url = 'https://btczexplorer.blockhub.info/ext/getbalance/t1ZYiG4R4n5gTgUKZRgVpKPzG5FYQXpEqga'; 
$http = new Client(['verify' => '/usr/lib/ssl/certs/cacert.pem']);
$options = [];
$response = $http->request('GET', $url, $options);
我得到了同样的错误:

cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) stack trace: #0 /var/www/html/bitpay/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(149): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array) #1 /var/www/html/bitpay/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(102): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory)) #2

我认为找到证书是个难题

因此,请尝试在php.ini中更改此选项(它需要一个绝对路径):


我认为找到证书是个难题

因此,请尝试在php.ini中更改此选项(它需要一个绝对路径):


你为什么要尝试使用本地证书或CA?你能说是哪个命令触发了这个吗?或者你没有在命令行上使用curl吗?如果你说你使用laravel,这个错误看起来有点奇怪。我已经在first postHmm中添加了响应,这取决于你的项目范围,这看起来相当复杂。你能不能不仅仅是
file_get_内容('https://btczexplorer.blockhub.info/ext/getbalance/t1ZYiG4R4n5gTgUKZRgVpKPzG5FYQXpEqga')
该怎么办?我已经添加到我的post响应中,因为它太长了。你为什么还要尝试使用本地证书或CA?你能说哪个命令会触发这个吗?或者你没有在命令行上使用curl吗?如果你说你使用laravel,错误似乎有点奇怪。我已经添加了对first postHmm的响应,这取决于你的项目范围这看起来很复杂。你能不能不只是
文件获取内容('https://btczexplorer.blockhub.info/ext/getbalance/t1ZYiG4R4n5gTgUKZRgVpKPzG5FYQXpEqga')
到此为止?我已经添加到我的帖子回复中,因为它太长了。抱歉,但不起作用,仍然是相同的错误,我添加了您的行并重新启动apache,结果是sameOk,您确定您使用的是哪个版本的php.ini吗?(键入shell“php--ini”)可以在php.ini中检查的所有条件是:1)取消注释“extension=openssl”2)在curl.cainfo、openssl.cafile、openssl.capath中编写相同的路径抱歉,但不起作用,仍然是相同的错误,我添加了您的行并重新启动apache,结果是sameOk,您确定使用哪个版本的php.ini吗?(键入shell“php--ini”)可以在php.ini中检查的所有条件是:1)取消注释”extension=openssl“2)在curl.cainfo、openssl.cafile、openssl.capath中写入相同的路径