Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
amazonwebservices committed Jun 8, 2011
1 parent b98a5de commit cd73cd2
Show file tree
Hide file tree
Showing 19 changed files with 775 additions and 604 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ The source tree for includes the following files and directories:
run on your server to determine whether or not your PHP environment meets the minimum requirements.
* `_docs` -- Informational documents, the contents of which should be fairly self-explanatory.
* `_samples` -- Code samples that you can run out of the box.
* `extensions` -- Extra code that can be used to enhance usage of the SDK, but isn't a service class or a
third-party library.
* `lib` -- Contains any third-party libraries that the SDK depends on. The licenses for these projects will
always be Apache 2.0-compatible.
* `services` -- Contains the service-specific classes that communicate with AWS. These classes are always
Expand Down Expand Up @@ -112,7 +114,10 @@ From the command-line, you can install the SDK with PEAR as follows:
pear channel-discover pear.amazonwebservices.com
pear install aws/sdk

You may need to use `sudo` for the above commands.
You may need to use `sudo` for the above commands. Once the SDK has been installed via PEAR, you can load it into
your project with:

require_once 'AWSSDKforPHP/sdk.class.php';

### Configuration

Expand Down
31 changes: 31 additions & 0 deletions _docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
# Changelog: "Nero"

Launched Tuesday, June 7, 2011

## Bug fixes and enhancements
* [Bug in PHP SDK](https://forums.aws.amazon.com/thread.jspa?threadID=67502)
* [cURL error: SSL certificate problem (60) with aws-sdk-for-php 1.3.3](https://forums.aws.amazon.com/thread.jspa?threadID=68349)


## Service Classes
### AmazonEC2
* **New:** Support for Local Availability Zone Pricing has been added to the SDK.

### AmazonELB
* **New:** Elastic Load Balancing provides a special Amazon EC2 security group that you can use to ensure that a back-end Amazon EC2 instance receives traffic only from its load balancer.

### AmazonRDS
* **New:** Support for Oracle databases has been added to the SDK.


## Utility Classes
### CFArray
* **New:** Added the init() method which simplifies the process of instantiating and chaining a class.
* **New:** Added support for associative arrays to `each()`, `map()` and `filter()`.

### CFRequest
* **New:** Now supports the `AWS_CERTIFICATE_AUTHORITY` configuration option.


----

# Changelog: 1.3.3 "Moogle"

Launched Tuesday, May 10, 2011
Expand Down
13 changes: 12 additions & 1 deletion config-sample.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Stores your AWS account information. Add your account information, and then rename this file
* to 'config.inc.php'.
*
* @version 2011.01.20
* @version 2011.06.02
* @license See the included NOTICE.md file for more information.
* @copyright See the included NOTICE.md file for more information.
* @link http://aws.amazon.com/php/ PHP Developer Center
Expand Down Expand Up @@ -41,6 +41,17 @@
*/
define('AWS_CANONICAL_NAME', '');

/**
* Determines which Cerificate Authority file to use.
*
* A value of boolean `false` will use the Certificate Authority file available on the system. A value of
* boolean `true` will use the Certificate Authority provided by the SDK. Passing a file system path to a
* Certificate Authority file (chmodded to `0755`) will use that.
*
* Leave this set to `false` if you're not sure.
*/
define('AWS_CERTIFICATE_AUTHORITY', false);

/**
* 12-digit serial number taken from the Gemalto device used for Multi-Factor Authentication. Ignore this
* if you're not using MFA.
Expand Down
39 changes: 33 additions & 6 deletions lib/requestcore/requestcore.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Handles all HTTP requests using cURL and manages the responses.
*
* @version 2011.03.01
* @version 2011.06.07
* @copyright 2006-2011 Ryan Parman
* @copyright 2006-2010 Foleeo Inc.
* @copyright 2010-2011 Amazon.com, Inc. or its affiliates.
Expand Down Expand Up @@ -99,7 +99,7 @@ class RequestCore
/**
* Default useragent string to use.
*/
public $useragent = 'RequestCore/1.4.2';
public $useragent = 'RequestCore/1.4.3';

/**
* File to read from while streaming up.
Expand Down Expand Up @@ -136,6 +136,16 @@ class RequestCore
*/
public $seek_position = null;

/**
* The location of the cacert.pem file to use.
*/
public $cacert_location = false;

/**
* The state of SSL certificate verification.
*/
public $ssl_verification = true;

/**
* The user-defined callback function to call when a stream is read from.
*/
Expand Down Expand Up @@ -608,10 +618,27 @@ public function prep_request()
curl_setopt($curl_handle, CURLOPT_USERAGENT, $this->useragent);
curl_setopt($curl_handle, CURLOPT_READFUNCTION, array($this, 'streaming_read_callback'));

// Verify security of the connection
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYHOST, true);
curl_setopt($curl_handle, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem'); // chmod the file as 0755
// Verification of the SSL cert
if ($this->ssl_verification)
{
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYHOST, true);
}
else
{
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYHOST, false);
}

// chmod the file as 0755
if ($this->cacert_location === true)
{
curl_setopt($curl_handle, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');
}
elseif (is_string($this->cacert_location))
{
curl_setopt($curl_handle, CURLOPT_CAINFO, $this->cacert_location);
}

// Debug mode
if ($this->debug_mode)
Expand Down
34 changes: 31 additions & 3 deletions sdk.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ function __aws_sdk_ua_callback()
// INTERMEDIARY CONSTANTS

define('CFRUNTIME_NAME', 'aws-sdk-php');
define('CFRUNTIME_VERSION', '1.3.3');
define('CFRUNTIME_VERSION', '1.3.4');
// define('CFRUNTIME_BUILD', gmdate('YmdHis', filemtime(__FILE__))); // @todo: Hardcode for release.
define('CFRUNTIME_BUILD', '20110510205648');
define('CFRUNTIME_BUILD', '20110607180731');
define('CFRUNTIME_USERAGENT', CFRUNTIME_NAME . '/' . CFRUNTIME_VERSION . ' PHP/' . PHP_VERSION . ' ' . php_uname('s') . '/' . php_uname('r') . ' Arch/' . php_uname('m') . ' SAPI/' . php_sapi_name() . ' Integer/' . PHP_INT_MAX . ' Build/' . CFRUNTIME_BUILD . __aws_sdk_ua_callback());


Expand All @@ -115,7 +115,7 @@ function __aws_sdk_ua_callback()
* Core functionality and default settings shared across all SDK classes. All methods and properties in this
* class are inherited by the service-specific classes.
*
* @version 2011.05.10
* @version 2011.06.07
* @license See the included NOTICE.md file for more information.
* @copyright See the included NOTICE.md file for more information.
* @link http://aws.amazon.com/php/ PHP Developer Center
Expand Down Expand Up @@ -229,6 +229,11 @@ class CFRuntime
*/
public $use_ssl = true;

/**
* The state of SSL certificate verification.
*/
public $ssl_verification = true;

/**
* The proxy to use for connecting.
*/
Expand Down Expand Up @@ -520,14 +525,36 @@ public function allow_hostname_override($override = true)
* Disables SSL/HTTPS connections for hosts that don't support them. Some services, however, still
* require SSL support.
*
* This method will throw a user warning when invoked, which can be hidden by changing your
* <php:error_reporting()> settings.
*
* @return $this A reference to the current instance.
*/
public function disable_ssl()
{
trigger_error('Disabling SSL connections is potentially unsafe and highly discouraged.', E_USER_WARNING);
$this->use_ssl = false;
return $this;
}

/**
* Disables the verification of the SSL Certificate Authority. Doing so can enable an attacker to carry
* out a man-in-the-middle attack.
*
* https://secure.wikimedia.org/wikipedia/en/wiki/Man-in-the-middle_attack
*
* This method will throw a user warning when invoked, which can be hidden by changing your
* <php:error_reporting()> settings.
*
* @return $this A reference to the current instance.
*/
public function disable_ssl_verification($ssl_verification = false)
{
trigger_error('Disabling the verification of SSL certificates can lead to man-in-the-middle attacks. It is potentially unsafe and highly discouraged.', E_USER_WARNING);
$this->ssl_verification = $ssl_verification;
return $this;
}

/**
* Enables HTTP request/response header logging to `STDERR`.
*
Expand Down Expand Up @@ -1007,6 +1034,7 @@ public function authenticate($action, $opt = null, $domain = null, $signature_ve
// Update RequestCore settings
$request->request_class = $this->request_class;
$request->response_class = $this->response_class;
$request->ssl_verification = $this->ssl_verification;

$curlopts = array();

Expand Down
32 changes: 12 additions & 20 deletions services/as.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,11 @@
*
* <b>Endpoints</b>
*
* Auto Scaling supports the following region-specific endpoints:
* For information about this product's regions and endpoints, go to <a
* href="http://docs.amazonwebservices.com/general/latest/gr/index.html?rande.html">Regions and Endpoints</a> in the Amazon Web Services
* General Reference.
*
* <ul> <li>autoscaling.us-east-1.amazonaws.com</li>
*
* <li>autoscaling.us-west-1.amazonaws.com</li>
*
* <li>autoscaling.eu-west-1.amazonaws.com</li>
*
* <li>autoscaling.ap-southeast-1.amazonaws.com</li>
*
* </ul>
*
* @version Tue May 10 18:23:42 PDT 2011
* @version Tue Jun 07 16:11:09 PDT 2011
* @license See the included NOTICE.md file for complete information.
* @copyright See the included NOTICE.md file for complete information.
* @link http://aws.amazon.com/autoscaling/Amazon Auto-Scaling
Expand Down Expand Up @@ -526,10 +518,10 @@ public function delete_auto_scaling_group($auto_scaling_group_name, $opt = null)
* @param integer $max_size (Required) The maximum size of the Auto Scaling group.
* @param string|array $availability_zones (Required) A list of availability zones for the Auto Scaling group. Pass a string for a single value, or an indexed array for multiple values.
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
* <li><code>DesiredCapacity</code> - <code>integer</code> - Optional - The number of EC2 instances that should be running in the group. </li>
* <li><code>DesiredCapacity</code> - <code>integer</code> - Optional - The number of EC2 instances that should be running in the group. For more information, see SetDesiredCapacity. </li>
* <li><code>DefaultCooldown</code> - <code>integer</code> - Optional - The amount of time, in seconds, after a scaling activity completes before any further trigger-related scaling activities can start. </li>
* <li><code>LoadBalancerNames</code> - <code>string|array</code> - Optional - A list of LoadBalancers to use. Pass a string for a single value, or an indexed array for multiple values. </li>
* <li><code>HealthCheckType</code> - <code>string</code> - Optional - The service you want the health status from, Amazon EC2 or Elastic Load Balancer. </li>
* <li><code>HealthCheckType</code> - <code>string</code> - Optional - The service you want the health status from, Amazon EC2 or Elastic Load Balancer. Valid values are "EC2" or "ELB." </li>
* <li><code>HealthCheckGracePeriod</code> - <code>integer</code> - Optional - Length of time in seconds after a new EC2 instance comes into service that Auto Scaling starts checking its health. </li>
* <li><code>PlacementGroup</code> - <code>string</code> - Optional - Physical location of your cluster placement group created in Amazon EC2. </li>
* <li><code>VPCZoneIdentifier</code> - <code>string</code> - Optional - The subnet identifier of the Virtual Private Cloud. </li>
Expand Down Expand Up @@ -688,7 +680,7 @@ public function set_instance_health($instance_id, $health_status, $opt = null)
* <li><code>AvailabilityZones</code> - <code>string|array</code> - Optional - Availability zones for the group. Pass a string for a single value, or an indexed array for multiple values. </li>
* <li><code>HealthCheckType</code> - <code>string</code> - Optional - The service of interest for the health status check, either "EC2" for Amazon EC2 or "ELB" for Elastic Load Balancing. </li>
* <li><code>HealthCheckGracePeriod</code> - <code>integer</code> - Optional - The length of time that Auto Scaling waits before checking an instance's health status. The grace period begins when an instance comes into service. </li>
* <li><code>PlacementGroup</code> - <code>string</code> - Optional - The name of the cluster placement group, if applicable. For more information, go to Using Cluster Instances in the Amazon EC2 User Guide. </li>
* <li><code>PlacementGroup</code> - <code>string</code> - Optional - The name of the cluster placement group, if applicable. For more information, go to Using Cluster Instances in the <i>Amazon EC2 User Guide</i>. </li>
* <li><code>VPCZoneIdentifier</code> - <code>string</code> - Optional - The identifier for the VPC connection, if applicable. </li>
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
Expand Down Expand Up @@ -826,15 +818,15 @@ public function resume_processes($auto_scaling_group_name, $opt = null)
* configurations must not yet have been met, or else the call will fail.
*
* @param string $launch_configuration_name (Required) The name of the launch configuration to create.
* @param string $image_id (Required) Unique ID of the <i>Amazon Machine Image</i> (AMI) which was assigned during registration. For more information about Amazon EC2 images, please see Amazon EC2 product documentation
* @param string $instance_type (Required) The instance type of the EC2 instance. For more information about Amazon EC2 instance types, please see Amazon EC2 product documentation
* @param string $image_id (Required) Unique ID of the <i>Amazon Machine Image</i> (AMI) which was assigned during registration. For more information about Amazon EC2 images, please go to Using AMIs in the <i>Amazon EC2 User Guide</i>
* @param string $instance_type (Required) The instance type of the EC2 instance. For more information about Amazon EC2 instance types, please go to Using Instances in the <i>Amazon EC2 User Guide</i>.
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
* <li><code>KeyName</code> - <code>string</code> - Optional - The name of the EC2 key pair. </li>
* <li><code>SecurityGroups</code> - <code>string|array</code> - Optional - The names of the security groups with which to associate EC2 instances. For more information about Amazon EC2 security groups, go to the Amazon EC2 product documentation. Pass a string for a single value, or an indexed array for multiple values. </li>
* <li><code>UserData</code> - <code>string</code> - Optional - The user data available to the launched EC2 instances. For more information about Amazon EC2 user data, please see Amazon EC2 product documentation. </li>
* <li><code>SecurityGroups</code> - <code>string|array</code> - Optional - The names of the security groups with which to associate EC2 instances. For more information about Amazon EC2 security groups, go to Using Security Groups in the <i>Amazon EC2 User Guide</i>. Pass a string for a single value, or an indexed array for multiple values. </li>
* <li><code>UserData</code> - <code>string</code> - Optional - The user data available to the launched EC2 instances. For more information about Amazon EC2 user data, please go to Using Instances in the <i>Amazon EC2 User Guide</i>. </li>
* <li><code>KernelId</code> - <code>string</code> - Optional - The ID of the kernel associated with the EC2 AMI. </li>
* <li><code>RamdiskId</code> - <code>string</code> - Optional - The ID of the RAM disk associated with the EC2 AMI. </li>
* <li><code>BlockDeviceMappings</code> - <code>array</code> - Optional - A list of mappings that specify how block devices are exposed to the instance. Each mapping is made up of a <i>VirtualName</i>, a <i>DeviceName</i>, and an <i>ebs</i> data structure that contains information about the associated Elastic Block Storage volume. For more information about Amazon EC2 BlockDeviceMappings, please go to Block Device Mapping in the Amazon EC2 product documentation. <ul>
* <li><code>BlockDeviceMappings</code> - <code>array</code> - Optional - A list of mappings that specify how block devices are exposed to the instance. Each mapping is made up of a <i>VirtualName</i>, a <i>DeviceName</i>, and an <i>ebs</i> data structure that contains information about the associated Elastic Block Storage volume. For more information about Amazon EC2 BlockDeviceMappings, please go to Block Device Mapping in the <i>Amazon EC2 User Guide</i>. <ul>
* <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
* <li><code>VirtualName</code> - <code>string</code> - Optional - The virtual name associated with the device. </li>
* <li><code>DeviceName</code> - <code>string</code> - Required - The name of the device within Amazon EC2. </li>
Expand Down
Loading

0 comments on commit cd73cd2

Please sign in to comment.