Skip to content

Disable signing the payload when UnsignedPayload is set to true #3596

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"core": {
"changeLogMessages": [
"Disable signing the payload when the operation is modeled as having an UnsignedPayload set to true."
],
"type": "patch",
"updateMinimum": true
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
{
ProcessHeaderMembers("publicRequest", this.Operation.RequestHeaderMembers);
}

if (this.Operation.UnsignedPayload)
{
#>
request.DisablePayloadSigning = true;
<# }

// If there aren't any members that are marshalled as part of the body or streamed
if (this.Operation.UseQueryString)
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
#>

<#
if (this.Operation.UnsignedPayload)
{
#>
request.DisablePayloadSigning = true;
<# }

// If there aren't any members that are marshalled as part of the body or streamed
if(this.Operation.UseQueryString)
{
Expand Down
13 changes: 13 additions & 0 deletions generator/ServiceClientGeneratorLib/Operation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1072,5 +1072,18 @@ public List<OperationContextParameter> OperationContextParameters
}
}

/// <summary>
/// Determines if the payload shouldn't be signed.
/// </summary>
public bool UnsignedPayload
{
get
{
if (data[ServiceModel.UnsignedPayloadKey] != null && data[ServiceModel.UnsignedPayloadKey].IsBoolean)
return (bool)data[ServiceModel.UnsignedPayloadKey];

return false;
}
}
}
}
1 change: 1 addition & 0 deletions generator/ServiceClientGeneratorLib/ServiceModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class ServiceModel
public const string ResponseAlgorithmsKey = "responseAlgorithms";
public const string RequestCompressionKey = "requestcompression";
public const string EncodingsKey = "encodings";
public const string UnsignedPayloadKey = "unsignedPayload";

// shapes
public const string ShapesKey = "shapes";
Expand Down
3 changes: 1 addition & 2 deletions sdk/src/Core/Amazon.Runtime/Internal/DefaultRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,7 @@ public bool Suppress404Exceptions
/// Setting DisablePayloadSigning to true requires that the request is sent over a HTTPS
/// connection.</para>
/// <para>Under certain circumstances, such as uploading to S3 while using MD5 hashing, it may
/// be desireable to use UNSIGNED-PAYLOAD to decrease signing CPU usage. This flag only applies
/// to Amazon S3 PutObject and UploadPart requests.</para>
/// be desireable to use UNSIGNED-PAYLOAD to decrease signing CPU usage.</para>
/// <para>MD5Stream, SigV4 payload signing, and HTTPS each provide some data integrity
/// verification. If DisableMD5Stream is true and DisablePayloadSigning is true, then the
/// possibility of data corruption is completely dependant on HTTPS being the only remaining
Expand Down
3 changes: 1 addition & 2 deletions sdk/src/Core/Amazon.Runtime/Internal/IRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,7 @@ AWS4SigningResult AWS4SignerResult
/// Setting DisablePayloadSigning to true requires that the request is sent over a HTTPS
/// connection.</para>
/// <para>Under certain circumstances, such as uploading to S3 while using MD5 hashing, it may
/// be desireable to use UNSIGNED-PAYLOAD to decrease signing CPU usage. This flag only applies
/// to Amazon S3 PutObject and UploadPart requests.</para>
/// be desireable to use UNSIGNED-PAYLOAD to decrease signing CPU usage.</para>
/// <para>MD5Stream, SigV4 payload signing, and HTTPS each provide some data integrity
/// verification. If DisableMD5Stream is true and DisablePayloadSigning is true, then the
/// possibility of data corruption is completely dependant on HTTPS being the only remaining
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public IRequest Marshall(UploadReadSetPartRequest publicRequest)
request.Headers[Amazon.Util.HeaderKeys.ContentLengthHeader] =
request.ContentStream.Length.ToString(CultureInfo.InvariantCulture);
request.Headers[Amazon.Util.HeaderKeys.ContentTypeHeader] = "application/octet-stream";
request.DisablePayloadSigning = true;
request.UseQueryString = true;

request.HostPrefix = $"storage-";
Expand Down
Loading