0

我正在尝试在 PhP 中使用CloudConvert API,但出现以下错误

CURLE_SSL_CACERT (60)
Peer certificate cannot be authenticated with known CA certificates.

阅读他们的 API 源代码,我发现他们使用 GuzzleClient 来处理请求。我想如果我只是禁用 cURL 上的 SSL 验证,它会起作用。我只是不知道如何在全球范围内做到这一点。我知道如何处理请求:curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 但这对我没有帮助,因为我无法控制 CloudConvert 如何处理他们的 API 请求。

有谁知道如何解决这个问题?我正在使用 MAMP 和 macOS Sierra 运行我的项目。

谢谢你的帮助

4

1 回答 1

0

刚刚找到解决方案。正如我之前所说,CloudConvert API 可以在构造函数中使用 Guzzle 客户端,因此我创建了客户端并将证书设置为它:

    $client = new \GuzzleHttp\Client(['verify' => $this->config->application->sslDir . "cacert.pem" ]);
    $api = new Api("xxxxxxx", $client);

        $api->convert([
            'inputformat' => 'html',
            'outputformat' => 'docx',
            'input' => 'upload',
            'file' => fopen('/Users/andre/Projects/x/Quote.html', 'r'),
        ])
            ->wait()
            ->download('/Users/andre/Projects/x/Quote.docx');
于 2017-03-15T15:43:16.130 回答