S3-php5-curl on an AWS EC2 instance - the requested domain name does not match the server certificate

I am using s3-php5-curl to access my AWS S3 carpet.

The function getBucket()works fine and returns the result when I host the PHP application myself, but when I put the same code into the AWS EC2 instance (by default, AIM is Linux, Apache, PHP), I get the following error

Warning: S3::getBucket(): [51] Unable to communicate securely with peer: requested domain name does not match the server certificate. In /var/www/html/s3-php5-curl/S3.php on line 136 Warning: Invalid argument supplied for foreach() in /var/www/html/index.php on line 15

I can’t figure it out. What does this mean and how can I solve it?

EDIT: I noticed this as an answer, but I was wrong. I got in touch with the fact that the main problem seems to be whether you use the Amazon SDK or the php5-curl library. There seems to be a common problem affecting EC2 users in some regions who are trying to programmatically access their S3 buckets related to SSL certification, where the bucket name includes a full stop (aka period). It has been documented, but contains unresolved here .

+5
source share
3 answers

Try using the AWS SDK for PHP 1.5.5 and make sure you specify your region and set path_styleto true. For me, I am in Singapore, so my code will be:

 $s3 = new AmazonS3();
 $s3->set_region(AmazonS3::REGION_APAC_SE1);
 $s3->path_style = true;

It seems to work for me.

, !

Cheers, Ardy

+4

Unable to communicate securely with peer: requested domain name does not match the server certificate.

, CURL . curl, .

, , : http://aws.amazon.com/sdkforphp/

+2

CURL SSL, s3-php5-curl/S3.php 1298-1299 :

curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

, x.z.s3.amazonaws.com, , SSL- *.s3.amazonaws.com .

+2

All Articles