curl - 设置证书验证位置时出错(Vagrant、Guzzle、curl)

标签 curl vagrant guzzle

我有一个 Vagrant 盒子设置并正在运行。我正在尝试使用 Guzzle 连接到第三方服务的 API。

据我所知,验证证书或来自 vagrant box(虚拟机和 API 服务器)的某些内容时遇到一些问题。

如有任何建议,我们将不胜感激,谢谢。

这是我返回的错误:

Fatal error:  Uncaught exception 'Guzzle\Http\Exception\CurlException' with message '[curl] 77: error setting certificate verify locations:
  CAfile: phar:///vagrant/web/vendor/guzzle.phar/src/Guzzle/Http/Resources/cacert.pem
  CApath: /etc/ssl/certs
 [url] https://www.domain.com/json/list?id=444&app_key=AAA [info] array (
  'url' => 'https://www.domain.com/json/list?id=444&app_key=AAA',
  'content_type' => NULL,
  'http_code' => 0,
  'header_size' => 0,
  'request_size' => 0,
  'filetime' => -1,
  'ssl_verify_result' => 0,
  'redirect_count' => 0,
  'total_time' => 0.141022,
  'namelookup_time' => 0.048923,
  'connect_time' => 0.141025,
  'pretransfer_time' => 0,
  'size_upload' => 0,
  'size_download' => 0,
  'speed_download' => 0,
  'speed_upload' => 0,
  'download_content_length' => -1,
  'upload_content_length' => -1,
  'starttransfer_time' => 0,
  'redirect_time' => 0,
  'certinfo' => 
  array (
  ),
  'redirect_url' => '',
) [debug]  in phar:///vagrant/web/vendor/guzzle.phar/src/Guzzle/Http/Curl/CurlMulti.php on line 555

最佳答案

这是先前版本的 Guzzle phar 文件的问题。 PHP 的curl 绑定(bind)不支持从phar 流包装器读取cacert 文件:

CAfile: phar:///vagrant/web/vendor/guzzle.phar/src/Guzzle/Http/Resources/cacert.pem

如果您从 Phar 运行,我已经更新了 Phar 的更高版本,以便在系统上使用 cacert bundle 。

关于curl - 设置证书验证位置时出错(Vagrant、Guzzle、curl),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13288680/

相关文章:

linux - 意外的 EOF、缺少引号或反引号?

vagrant - 执行 `VBoxManage`(VBoxManage : error: Details: code NS_ERROR_FAILURE (0x80004005), 组件)时出错

ruby-on-rails - percise32 vagrant box 上的 Rails 应用程序 - Assets 出现 "text file busy"错误 (Errno::ETXTBSY)

Laravel - 获取客户端 IP 地址 - 总是得到 127.0.0.1 结果

php - 如何在 Guzzle 通话中通过登录屏幕

php - Laravel - 在 SQL 数据库中存储 JSON 响应(通过 Guzzle)

PHP 多 cURL 性能比顺序 file_get_contents 差

php - 如何使用 CURL 在 Facebook 页面上发布帖子而不在 PHP 中使用 SDK

Vagrant 同步文件夹使用 NFS 错误权限

php - 如何使用cURL和PHP从使用SSL的网站获取数据?