protected string CreateStringToSign <T>(string canonicalRequest, SignerRequestParams <T> signerParams) { var stringToSignBuilder = new StringBuilder(signerParams.GetSigningAlgorithm()); stringToSignBuilder.Append("\n") .Append(signerParams.GetFormattedSigningDateTime()) .Append("\n") .Append(signerParams.GetScope()) .Append("\n") .Append(BinaryUtils.ToHex(this.Hash(canonicalRequest))); var stringToSign = stringToSignBuilder.ToString(); return(stringToSign); }
private string BuildAuthorizationHeader <T>(IRequest <T> request, byte[] signature, ICredentials credentials, SignerRequestParams <T> signerParams) { var signingCredentials = credentials.GetAccessKeyId() + "/" + signerParams.GetScope(); var credential = "Credential=" + signingCredentials; var signerHeaders = "SignedHeaders=" + this.GetSignedHeadersString(request); var signatureHeader = "Signature=" + BinaryUtils.ToHex(signature); var authHeaderBuilder = new StringBuilder(); authHeaderBuilder.Append("SDK-HMAC-SHA256") .Append(" ") .Append(credential) .Append(", ") .Append(signerHeaders) .Append(", ") .Append(signatureHeader); return(authHeaderBuilder.ToString()); }