LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-31-2013, 06:51 AM   #1
sudi267
LQ Newbie
 
Registered: Sep 2012
Distribution: debian ubuntu
Posts: 10

Rep: Reputation: Disabled
Question sign the request query for aws ec2 api


how to calculate signature for query request of amazon aws ec2 api
i did like this
Code:
#!/bin/bash
q='GET
ec2.amazonaws.com
/
AWSAccessKeyId=<aws access key>&Action=DescribeRegions&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2013-05-31T12%3A45%3A00Z&Version=2013-02-01'

echo -en "$q" | openssl dgst -sha256 -hmac "<aws secret key>" -binary | openssl enc -base64
i get the signature as nv9bPT7V82RKZfoG7mAtnxbdiGyoKLgi2jxjuUv29jw=


now again i do curl request with following cmd

$ curl --get --data-urlencode DATA "https://ec2.amazonaws.com/?Action=DescribeRegions&AWSAccessKeyId=<aws access key>&Timestamp=2013-05-31T12:45:00Z&Version=2013-02-01&SignatureVersion=2&SignatureMethod=HmacSHA256&Signature=nv9bPT7V82RKZfoG7mAtnxbdiGyoKLgi2jxjuUv29 jw="

i get xml response from amazon aws as
Code:
 
<Response>
<Errors><Error>
<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.</Message></Error></Errors>
<RequestID>3d695345-59ef-4339-98ab-7f9462a90179</RequestID></Response>
i m sure that my aws access key and aws secret key are proper coz they work for ec2 cli tools but when making ec2 api request i get this error

can any1 tell me is the method of generating signature proper
using openssl
 
Old 05-31-2013, 09:22 AM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip is version 1.6.7.2,
or was when I downloaded it over a month ago...Now it is 1.6.7.3

What version are you dealing with?

Seen this
http://docs.aws.amazon.com/general/l...signature.html
http://docs.aws.amazon.com/ElasticMa...signature.html
both from http://goo.gl/5w5pA

Last edited by Habitual; 05-31-2013 at 09:26 AM.
 
Old 06-03-2013, 08:03 AM   #3
sudi267
LQ Newbie
 
Registered: Sep 2012
Distribution: debian ubuntu
Posts: 10

Original Poster
Rep: Reputation: Disabled
sign the request query for aws ec2 api

i don't want to use ec2 command line tools;i.e ec2-api-tools-any version
i m doing it through pure http web request only.
i need the output in xml format.
so i asked what is wrong in generating signature for the request query coz i m getting error in xml response
i followed aws docs only and accordingly i wrote the script for generating api signature
but still getting same xml response:

"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details"
 
Old 06-03-2013, 02:05 PM   #4
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by sudi267 View Post
i don't want to use ec2 command line tools;i.e ec2-api-tools-any version
i m doing it through pure http web request only.
i need the output in xml format.
so i asked what is wrong in generating signature for the request query coz i m getting error in xml response
i followed aws docs only and accordingly i wrote the script for generating api signature
but still getting same xml response:

"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details"
Since I use ec2-api every day, I saw #!/bin/bash and assumed a c-li. Sorry, fresh out.
https://forums.aws.amazon.com/thread...ssageID=288617 may be able to help.
 
  


Reply

Tags
aws, bash scripting, linux


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Amazon's AWS/EC2 CentOS instances cannot talk to each other ronbarak Linux - Networking 3 05-05-2013 05:27 AM
how to do an http request using linux API sha_neb Linux - Networking 7 05-22-2010 12:13 AM
API for htttp request sha_neb Linux - Software 1 05-21-2010 03:56 PM
LXer: LINQ is the best option for a future Java query API LXer Syndicated Linux News 0 08-29-2008 12:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration