gpt4 book ai didi

php - 调用 API 时出现 cURL 错误。 cURL 错误编号 :[60] SSL certificate prob: self signed certificate in certificate chain

转载 作者:太空宇宙 更新时间:2023-11-03 13:22:31 31 4
gpt4 key购买 nike

美好的一天,我是服务器设置的新手。我目前正在使用 laravel 5.4 来集成我的 quickbooks app在我的实时服务器上 http://qb.dagnum.com/connect但我继续收到此错误

(1/1) SdkException
cURL error during making API call. cURL Error Number:[60] with error:[SSL certificate problem: self signed certificate in certificate chain]

我使用“composer require quickbooks/v3-php-sdk”添加了包。服务器也安装了 SSL 证书,但我仍然收到错误。

我的代码:

use App\Http\Controllers\Controller;   
use QuickBooksOnline\API\DataService\DataService;

class Auth2Controller extends Controller
{
public function index()
{

$dataService = DataService::Configure(array(
'auth_mode' => 'oauth2',
'ClientID' => "Q0lCkcEshsGMHOEula2r5RKc2yhxvMsYEpKN1lw1WZwyfd1Si6",
'ClientSecret' => "gE0F9hLgwx9OBzRpNxyOvWJH6L2fIhzAwBugPJHq",
'accessTokenKey' => 'eyJlbmMiOiJBMTI4Q0JDLUhTMjU2IiwiYWxnIjoiZGlyIn0..4z4Assj4x1qt8H4DtQco6A.nmV2jTxaDMVdFWEUO16q5qhbd5aD6U-U-RYnSNywqg-HPC_3_jvwpMJU1a1S5X-PgPUy60WvVy_8p1awY7kIoFzTV4IhdFLrZpYtBUGCjcsvjxWeOSgP6oCayBEmCv7zzabtgB6vxU46jQqKX2IXYUGPPtyYO64hrgELFR4SKUK6boZiVnh8z19gnvsReKMmIINA3-NgC6QJqMRp6HWgzCa9RuDN9tCtrAK2dy5xmJRNSNgdv_gyg1bfdX4l4b30fLPzFk31fsTT9NTJq9PuGtdTsvUuCj7Hme6HPldD9TKYRXWU8TKrQQrQWEpdlbPr6F3rhP6IdmCv9t1XH_WzF_1IseRUoYhiTUjubig-j8gzwajIdYQTzpJQKJ92QiAEyt8k40WWg0v69hEC0w7WRBuUE-IJ50xWypqS_P28IWt1G14rovZ97soGOteSik-41g1icR2zxfNhXGq7zO7oU5B8r-ej5Pb52T0MCMktgd6y32bqwo2pcEzblL2bZs7DZ7LDx5peY4TIfGW21crTE6xjhRr7LdqB8K505pRqIOP20eaRgwtGHLZ3bdBt1_negw2AGjc409BM0nLzzmODxr3yo-YdGwkcOjm5QgbGAsrnpoSo9tSpxPHoN0vMRneRdsKCd6CZG5M1OIOMuj7spkm442tvwiAMCx2Fh-STG6fMnhOq7l_f8NW_3kscxtF2.obQxJKjPfi1KlaQQ_OUoNg',
'refreshTokenKey' => "L011509163184Q0K7DT40SVXhJXAfyoj6B6EbSr3Ty64yVvF5A",
'QBORealmID' => "123145857569084",
'baseUrl' => "https://sandbox-quickbooks.api.intuit.com"
));

$dataService->setMinorVersion("9");
$CompanyInfo = $dataService->getCompanyInfo();
$error = $dataService->getLastError();

if ($error != null) {
echo "The Status code is: " . $error->getHttpStatusCode() . "\n";
echo "The Helper message is: " . $error->getOAuthHelperError() . "\n";
echo "The Response message is: " . $error->getResponseBody() . "\n";
echo "The Intuit Helper message is: IntuitErrorType:{" . $error->getIntuitErrorType() . "} IntuitErrorCode:{" . $error->getIntuitErrorCode() . "} IntuitErrorMessage:{" . $error->getIntuitErrorMessage() . "} IntuitErrorDetail:{" . $error->getIntuitErrorDetail() . "}";
}

}

我也看到了curl函数

private function setSSL(&$curl_opt, $verifySSL){
if($verifySSL){
$curl_opt[CURLOPT_SSL_VERIFYPEER] = true;
$curl_opt[CURLOPT_SSL_VERIFYHOST] = 2;
$curl_opt[CURLOPT_CAINFO] = dirname(dirname(__FILE__)) . "/OAuth/OAuth2/certs/apiintuitcom.pem"; //Pem certification Key Path
}
}

尝试替换

$curl_opt[CURLOPT_CAINFO] = dirname(dirname(__FILE__)) . "/OAuth/OAuth2/certs/apiintuitcom.pem";

to `$curl_opt[CURLOPT_CAINFO] ="/home/servername/public_html/quickbooks_app/resources/cert/cacert.pem";`

但是我得到这个错误 Http 状态代码:[401] Http 响应主体为空或空。

请问我应该怎么做才能解决这个问题..

最佳答案

我已经删除了 SDK 附带的 apiintuitcom.pem 文件,并开始使用 cacert.pem,您可以在 PHP_OAuth2.0 上找到它。示例应用程序。我也使用了错误的 baseUrl 但我用你的改变了。这为我修复了错误。我的 setSSL 方法现在看起来像这样:

private function setSSL(&$curl_opt, $verifySSL){
if($verifySSL){
$curl_opt[CURLOPT_SSL_VERIFYPEER] = true;
$curl_opt[CURLOPT_SSL_VERIFYHOST] = 2;
$curl_opt[CURLOPT_CAINFO] = dirname(dirname(__FILE__)) . "/OAuth/OAuth2/certs/cacert.pem"; //Pem certification Key Path
}
}

我的 $dataService 和你的差不多。

关于php - 调用 API 时出现 cURL 错误。 cURL 错误编号 :[60] SSL certificate prob: self signed certificate in certificate chain,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45472928/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com