Braintree PHP 客户端库和 Google App Engine CURLOPT_CAINFO 未实现

Braintree PHP client library, and Google App Engine CURLOPT_CAINFO not implemented

我正在将应用程序部署到 Google App Engine standard 环境,PHP 5.5,但是在通过 Braintree [=34] 发出任何请求时遇到以下问题=]图书馆:

PHP Fatal error:  Uncaught exception 'google\appengine\runtime\CurlLiteOptionNotSupportedException' with message     'Option 10065 is not supported by this curl implementation.' in /base/php_experiment_runtime/sdk/google/appengine/runtime/CurlLite.php:487
Stack trace:
#0 /base/php_experiment_runtime/sdk/google/appengine/runtime/CurlLite.php(215): google\appengine\runtime\CurlLite->setOption(10065, '/base/data/home...')
#1 /base/php_experiment_runtime/sdk/google/appengine/runtime/CurlLiteStub.php(1325): google\appengine\runtime\CurlLite->setOptionsArray(Array)
#2 /base/php_experiment_runtime/sdk/google/appengine/runtime/CurlLiteStub.php(1319): curl_setopt_array(Object(google\appengine\runtime\CurlLite), Array)
#3 /base/data/home/apps/s~enoronbackend/20170630t135950.402337515471573447/vendor/braintree/braintree_php/lib/Braintree/Http.php(135): curl_setopt(Object(google\appengine\runtime\CurlLite), 10065, '/base/data/home...')
#4 /base/data/home/apps/s~enoronbackend/20170630t135950.402337515471573447/vendor/braintree/braintree_php/li in /base/php_experiment_runtime/sdk/google/appengine/runtime/CurlLite.php on line 487

我确实设置了没有指定 gzip 响应的库,如 here 所示。

Braintree\Configuration::environment('production');
Braintree\Configuration::merchantId('XXX');
Braintree\Configuration::publicKey('XXX');
Braintree\Configuration::privateKey('XXX');
Braintree\Configuration::acceptGzipEncoding(false);

然而,问题似乎是由 Braintree\Http 中的第 133 行引起的:

curl_setopt($curl, CURLOPT_CAINFO, $this->getCaFile());

GAE 提供的 cUrl lite 实现不支持 CURLOPT_CAINFO。我确实尝试使用 CURLOPT_CAPATH,正如 cUrl 上的 PHP 文档中所建议的那样,但随后我从 Braintree 收到了授权错误。

同时注释掉 CURLOPT_CAINFO 所在的行会导致授权错误。

万一有人感兴趣,事实证明解决方案非常简单,使用完整的 cUrl PHP 库而不是 GAE 提供的精简版。为此,您需要编辑 php.ini 文件:

而不是

google_app_engine.enable_curl_lite = “1”

使用

extension = "curl.so"