简体   繁体   English

AWS的PHP CURL错误

[英]PHP CURL error with AWS

I am experiencing a very strange error with AWS and the PHP SDK. 我在使用AWS和PHP SDK时遇到一个非常奇怪的错误。 I am able to connect to S3 with my PHP code and store objects in my bucket when using my local server on my laptop. 在笔记本电脑上使用本地服务器时,我可以使用PHP代码连接到S3并将对象存储在存储桶中。 I am also able to connect to S3 on our test/staging server. 我还可以连接到我们的测试/登台服务器上的S3。 However, on our production server, I keep getting the following error when I try to connect: 但是,在我们的生产服务器上,尝试连接时始终出现以下错误:

cURL resource: Resource id #8; cURL资源:资源ID#8; cURL error: Problem with the SSL CA cert (path? access rights?) (77) cURL错误:SSL CA证书有问题(路径?访问权限?)(77)

I have tried adding this line in the config.inc.php file for AWS SDK, which was a solution mentioned in the AWS forums: 我尝试将这一行添加到AWS开发工具包的config.inc.php文件中,这是AWS论坛中提到的解决方案:

define('AWS_CERTIFICATE_AUTHORITY', true); define('AWS_CERTIFICATE_AUTHORITY',true);

But the error still persists. 但是错误仍然存​​在。 Any idea what may be wrong or how I can trouble shoot something like this? 知道什么地方可能出问题了,或者我该如何解决此类问题?

Here's what it says in the Apache error log: 这是Apache错误日志中的内容:

About to connect() to mydb.s3.amazonaws.com port 443 (#0) * Trying 223.33.211.223... * connected * Connected to mydb.s3.amazonaws.com (223.33.211.223) port 443 (#0) * Initializing NSS with certpath: /etc/pki/nssdb * Unable to initialize NSS database * NSS error -8023 * Closing connection #0 * Problem with the SSL CA cert (path? access rights?) 即将连接()到mydb.s3.amazonaws.com端口443(#0)*尝试223.33.211.223 ... *已连接*已连接到mydb.s3.amazonaws.com(223.33.211.223)端口443(#0) *使用证书路径初始化NSS:/ etc / pki / nssdb *无法初始化NSS数据库* NSS错误-8023 *关闭连接#0 * SSL CA证书有问题(路径?访问权限?)

Cheers! 干杯!

In the code itself we can add the following line to avoid the fatal error for testing purpose. 在代码本身中,我们可以添加以下行,以避免出于测试目的的致命错误。

error_reporting(E_WARNING);

$s3 = new AmazonS3();
$s3->disable_ssl();
$s3->disable_ssl_verification();

Otherwise we will add the following line in our php.ini file at the end for SSL Certificate. 否则,我们会在php.ini文件的末尾添加以下行以获取SSL证书。

[PHP]
curl.cainfo = "C:\xampp\htdocs\aws\sdk\lib\requestcore\cacert.pem"

Turns out there was a problem with the NSS database. 原来NSS数据库存在问题。 The apache error logs were showing this: apache错误日志显示如下:

Initializing NSS with certpath: /etc/pki/nssdb * Unable to initialize NSS database * NSS error -8023 使用certpath初始化NSS:/ etc / pki / nssdb *无法初始化NSS数据库* NSS错误-8023

After generating a new NSS database and re-starting apache, the problem was resolved. 生成新的NSS数据库并重新启动apache之后,此问题已解决。

Also in version 1.5, they came out with an entirely new format for the config.inc.php file. 同样在1.5版中,它们为config.inc.php文件提供了全新的格式。 It's really nice if you manage multiple sets of credentials. 如果您管理多组凭据,这真的很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM