public SignRequest ( IRequest request, IClientConfig clientConfig, |
||
request | IRequest | /// The request to compute the signature for. Additional headers mandated by the AWS4 protocol /// ('host' and 'x-amz-date') will be added to the request before signing. /// |
clientConfig | IClientConfig | /// Client configuration data encompassing the service call (notably authentication /// region, endpoint and service name). /// |
metrics | /// Metrics for the request. /// | |
awsAccessKeyId | string | /// The AWS public key for the account making the service call. /// |
awsSecretAccessKey | string | /// The AWS secret key for the account making the call, in clear text. /// |
return |
public AWS4SigningResult SignRequest(IRequest request,
IClientConfig clientConfig,
RequestMetrics metrics,
string awsAccessKeyId,
string awsSecretAccessKey)
{
var signedAt = InitializeHeaders(request.Headers, request.Endpoint);
var service = DetermineService(clientConfig);
var region = DetermineSigningRegion(clientConfig, service, request.AlternateEndpoint, request);
var parametersToCanonicalize = GetParametersToCanonicalize(request);
var canonicalParameters = CanonicalizeQueryParameters(parametersToCanonicalize);
var bodyHash = SetRequestBodyHash(request);
var sortedHeaders = SortAndPruneHeaders(request.Headers);
var canonicalRequest = CanonicalizeRequest(request.Endpoint,
request.ResourcePath,
request.HttpMethod,
sortedHeaders,
canonicalParameters,
bodyHash);
if (metrics != null)
metrics.AddProperty(Metric.CanonicalRequest, canonicalRequest);
return ComputeSignature(awsAccessKeyId,
awsSecretAccessKey,
region,
signedAt,
service,
CanonicalizeHeaderNames(sortedHeaders),
canonicalRequest,
metrics);
}