public override void Sign(IRequest request, string awsAccessKeyId, string awsSecretAccessKey)
        {
            //请求指标
            var metrics = new RequestMetrics();
            SignerRequestParamsEx signerParams = new SignerRequestParamsEx(request, this.regionName, this.serviceName, "SDK-HMAC-SHA256");

            SignHttp(request, metrics, awsAccessKeyId, awsSecretAccessKey, signerParams);
        }
        private static void SignHttpEx(IRequest request, RequestMetrics metrics, string awsAccessKeyId,
                                       string awsSecretAccessKey, SignerRequestParamsEx param = null)
        {
            string date       = "20171006T170510Z"; //AWSSDKUtils.FormattedCurrentTimestampISO8601;
            string hostHeader = request.Endpoint.Host;

            request.Headers[HttpHeaderKeys.HostHeader] = hostHeader;
            request.Headers[HttpHeaderKeys.SdkData]    = date;
        }
        protected static String CreateStringToSign(String canonicalRequest, SignerRequestParamsEx signerParams)
        {
            byte[]        hhhhh = ComputeHash(canonicalRequest);
            string        hex   = AWSSDKUtils.ToHex(hhhhh, true);
            StringBuilder stringToSignBuilder = new StringBuilder("SDK-HMAC-SHA256");

            stringToSignBuilder.Append("\n")
            .Append(signerParams.GetFormattedSigningDateTime())
            .Append("\n")
            .Append(signerParams.GetScope())
            .Append("\n")
            .Append(hex);
            String stringToSign = stringToSignBuilder.ToString();

            return(stringToSign);
        }
        public override void Sign(IRequest request, ICredentials credentials)
        {
            var sanitizedCredentials = this.SanitizeCredentials(credentials);
            var signerParams         = new SignerRequestParamsEx(request, this.regionName, this.serviceName, "SDK-HMAC-SHA256");

            this.AddHostHeader(request);
            request.Headers.Add("X-Sdk-Date", signerParams.GetFormattedSigningDateTime());

            String contentSha256 = this.CalculateContentHash(request);

            if ("required".Equals(request.Headers["x-sdk-content-sha256"]))
            {
                request.Headers.Add("x-sdk-content-sha256", contentSha256);
            }

            var metrics = new RequestMetrics();

            SignHttp(request, metrics, sanitizedCredentials.GetAccessKeyId(), sanitizedCredentials.GetSecretKey(), signerParams);
        }
        private static void SignHttp(IRequest request, RequestMetrics metrics, string awsAccessKeyId, string awsSecretAccessKey, SignerRequestParamsEx param = null)
        {
            string hostHeader = request.Endpoint.Host;

            request.Headers[HttpHeaderKeys.HostHeader] = hostHeader;

            SigningAlgorithm algorithm = SigningAlgorithm.HmacSHA256;
            string           nonce     = Guid.NewGuid().ToString();
            string           date      = AWSSDKUtils.FormattedCurrentTimestampISO8601;
            bool             isHttps   = IsHttpsRequest(request);

            // Temporarily disabling the AWS3 HTTPS signing scheme and only using AWS3 HTTP
            isHttps = false;

            request.Headers[HttpHeaderKeys.SdkData] = date;

            // AWS3 HTTP requires that we sign the Host header
            // so we have to have it in the request by the time we sign.

            if (!request.Endpoint.IsDefaultPort)
            {
                hostHeader += ":" + request.Endpoint.Port;
            }


            byte[] bytesToSign = null;
            string stringToSign;
            Uri    url = request.Endpoint;

            if (!string.IsNullOrEmpty(request.ResourcePath))
            {
                url = new Uri(request.Endpoint, request.ResourcePath);
            }

            stringToSign = request.HttpMethod + "\n"
                           + GetCanonicalizedResourcePath(url) + "\n"
                           + GetCanonicalizedQueryString(request.Parameters) + "\n"
                           + GetCanonicalizedHeadersForStringToSign(request) + "\n"
                           + GetRequestPayload(request);

            String hehehe = CreateStringToSign(stringToSign, param);

            bytesToSign = CryptoUtilFactory.CryptoInstance.ComputeSHA256Hash(Encoding.UTF8.GetBytes(hehehe));

            metrics.AddProperty(Metric.StringToSign, stringToSign);
            string signature = AWSSDKUtils.ToHex(ComputeHash(bytesToSign, awsSecretAccessKey, algorithm, true), true);

            //this.ComputeSignature()


            StringBuilder builder = new StringBuilder();

            builder.Append("SDK-HMAC-SHA256");
            builder.Append(" ");
            builder.Append("Credential=" + awsAccessKeyId + "/20171006/cn-north-1/dis/sdk_request, ");
            //builder.Append("Algorithm=" + algorithm.ToString() + ",");
            builder.Append(GetSignedHeadersComponent(request) + ",");
            builder.Append("Signature=" + signature);
            string authorizationHeader = builder.ToString();

            request.Headers[HttpHeaderKeys.Authorization] = authorizationHeader;
        }