A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2009 yearHow can I generate a v2 signature for Amazon EC2 using PHP? - page 1
User InfoPosts
How can I generate a v2 signature for Amazon EC2 using PHP?#1
I am wondering if anyone has successfully generated an EC2 v2 signature for their API using php. All examples/libraries I can find online are for v1 of the signature and that has been deprecated due to insecurities. An existing library that implements the signature generation would be appreciated too.

posted date: 2009-04-07 16:01:00


Re: How can I generate a v2 signature for Amazon EC2 using PHP?#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2009-04-07 16:01:01


Re: How can I generate a v2 signature for Amazon EC2 using PHP?#3
Here(s a PHP Library that supports V2. I haven(t tried it though.

posted date: 2009-04-07 16:04:00


Re: How can I generate a v2 signature for Amazon EC2 using PHP?#4
Here(s some code I(ve written and have been using:define("AWSKEY", "Your AWS Key");define("AWSSECRET", "Your AWS Secret");public function get($parameters, $host) { // Build out the variables $domain = "https://$host/"; $parameters[(AWSAccessKeyId(] = AWSKEY; $parameters[(Timestamp(] = date((c(); $parameters[(Version(] = (2007-11-07(; $parameters[(SignatureMethod(] = (HmacSHA256(; $parameters[(SignatureVersion(] = 2; // Write the signature $signature = "GET\n"; $signature .= "$host\n"; $signature .= "/\n"; $sigparams = $parameters; ksort($sigparams); $first = true; foreach($sigparams as $key=>$param) { $signature .= (!$first ? (&( : (() . rawurlencode($key) . (=( . rawurlencode($param); $first = false; } $signature = hash_hmac((sha256(, $signature, $AWSKEY, true); $signature = base64_encode($signature); $parameters[(Signature(] = $signature; $url = $domain . (?(; $first = true; foreach($parameters as $key=>$param) { $url .= (!$first ? (&( : (() . rawurlencode($key) . (=( . rawurlencode($param); $first = false; } $ch = curl_init(trim($url)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); return $output;}Here(s how you(d use it:$params = array( (Action( => (ListDomains();$db->get($params, (sdb.amazonaws.com();This would perform a ListDomains query on SimpleDB. The function itself will return Amazon(s output. For more complicated commands, (i.e.: PUT, POST, etc.) there aren(t any major modifications that need to be made.

posted date: 2009-11-24 16:25:00


Re: How can I generate a v2 signature for Amazon EC2 using PHP?#5
http://mierendo.com/software/aws%5Fsigned%5Fquery/I believe that(s V2

posted date: 2009-11-24 16:34:00


Re: How can I generate a v2 signature for Amazon EC2 using PHP?#6
Use constant AWSSECRET to hash the signature, NOT $AWSKEY (an unreferenced variable).

posted date: 2012-05-12 23:28:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.