Skip to content

Instantly share code, notes, and snippets.

@failshell
Created April 11, 2016 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save failshell/09e492492e65f440d5837ff9fcdf1104 to your computer and use it in GitHub Desktop.
Save failshell/09e492492e65f440d5837ff9fcdf1104 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'aws-sdk-core'
require 'uri'
uri = URI('https://rds.amazonaws.com/v13/downloadCompleteLogFile/some_server/general/mysql-general.log.0')
credentials = Aws::Credentials.new('secret', 'secret')
signer = Aws::Signers::V4.new(credentials, 'rds', 'us-east-1')
req = Seahorse::Client::Http::Request.new(endpoint: uri)
signed_req = signer.sign(req)
authorization = signed_req.headers['authorization']
x_amz_date = signed_req.headers['x-amz-date']
puts `curl -v -H 'Authorization: #{authorization}' -H 'X-Amz-Date: #{x_amz_date}' https://rds.amazonaws.com/v13/downloadCompleteLogFile/some_server/general/mysql-general.log.0`
@failshell
Copy link
Author

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.

The Canonical String for this request should have been
'GET
/v13/downloadCompleteLogFile/some_server/general/mysql-general.log.0

host:rds.us-east-1.amazonaws.com
x-amz-content-sha256:
x-amz-date:20160411T144251Z

host;x-amz-content-sha256;x-amz-date
some_signature'

The String-to-Sign should have been
'AWS4-HMAC-SHA256
20160411T144251Z
20160411/us-east-1/rds/aws4_request
some_signature'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment