|« PreviousNext »|
|Did this page help you? Yes | No | Tell us about it...|
HTTP Query-based requests are HTTP requests that use the HTTP verb GET or POST
and a Query parameter named
Each Query request must include some common parameters to handle authentication and selection of an action.
Some operations take lists of parameters. These lists are specified using the
param. notation. Values
n are integers starting from 1.
For information about this product's regions and endpoints, go to Regions and Endpoints in the Amazon Web Services General Reference.
You can only send Query requests over HTTPS and you must include a signature in every Query request. You must use either a signature version 2 or signature version 4. This section describes how to create a signature version 2. For information about creating a signature version 4, see Signature Version 4 Signing Process.
The following are the basic steps used to authenticate requests to AWS. This assumes you are registered with AWS and have an Access Key ID and Secret Access Key.
Query Authentication Process
|1||The sender constructs a request to AWS.|
|2||The sender calculates the request signature, a Keyed-Hashing for Message Authentication Code (HMAC) with a SHA-1 hash function, as defined in the next section of this topic.|
|3||The sender of the request sends the request data, the signature, and Access Key ID (the key-identifier of the Secret Access Key used) to AWS.|
|4||AWS uses the Access Key ID to look up the Secret Access Key.|
|5||AWS generates a signature from the request data and the Secret Access Key using the same algorithm used to calculate the signature in the request.|
|6||If the signatures match, the request is considered to be authentic. If the comparison fails, the request is discarded, and AWS returns an error response.|
If a request contains a
Timestamp parameter, the
signature calculated for the request expires 15 minutes after its value. If a
request contains an
Expires parameter, the signature
expires at the time specified by the
Calculating the request signature
Create the canonicalized query string that you need later in this procedure:
Sort the UTF-8 query string components by parameter name with natural byte ordering. The parameters can come from the GET URI or from the POST body (when Content-Type is application/x-www-form-urlencoded).
URL encode the parameter name and values according to the following rules:
Do not URL encode any of the unreserved characters that RFC 3986 defines. These unreserved characters are A-Z, a-z, 0-9, hyphen ( - ), underscore ( _ ), period ( . ), and tilde ( ~ ).
Percent encode all other characters with %XY, where X and Y are hex characters 0-9 and uppercase A-F.
Percent encode extended UTF-8 characters in the form %XY%ZA....
Percent encode the space character as %20 (and not +, as common encoding schemes do).
Separate the encoded parameter names from their encoded values with the equals sign ( = ) (ASCII character 61), even if the parameter value is empty.
Separate the name-value pairs with an ampersand ( & ) (ASCII code 38).
Create the string to sign according to the following pseudo-grammar (the "\n" represents an ASCII newline).
StringToSign = HTTPVerb + "\n" + ValueOfHostHeaderInLowercase + "\n" + HTTPRequestURI + "\n" + CanonicalizedQueryString <from the preceding step>The HTTPRequestURI component is the HTTP absolute path component of the URI up to, but not including, the query string. If the HTTPRequestURI is empty, use a forward slash ( / ).
Calculate an RFC 2104-compliant HMAC with the string you just created, your Secret Access Key as the key, and SHA256 or SHA1 as the hash algorithm.
For more information, go to http://www.rfc.net/rfc2104.html.
Convert the resulting value to base64.
Include the value as the value of the
parameter in the request.
For example, the following is an example request (linebreaks added for clarity).
https://rds.amazonaws.com/ ?Action=DescribeDBInstances &DBInstanceIdentifier=myinstance &Version=2010-01-01 &Timestamp=2010-05-10T17%3A09%3A03.726Z &SignatureVersion=2 &SignatureMethod=HmacSHA256 &AWSAccessKeyId=<Your AWS Access Key ID>
For the preceding Query string, you would calculate the HMAC signature over the following string.
GET\n rds.amazonaws.com\n AWSAccessKeyId=<Your AWS Access Key ID> &Action=DescribeDBInstances &DBInstanceIdentifier=myinstance &Timestamp=2010-05-10T17%3A09%3A03.726Z &SignatureMethod=HmacSHA256 &SignatureVersion=2 &Version=2009-10-16
The result is the following signed request.
https://rds.amazonaws.com/ ?Action=DescribeDBInstances &DBInstanceIdentifier=myinstance &Version=2010-01-01 &Timestamp=2010-05-10T17%3A09%3A03.726Z &Signature=<URLEncode(Base64Encode(Signature))> &SignatureVersion=2 &SignatureMethod=HmacSHA256 &AWSAccessKeyId=<Your AWS Access Key ID>