diff --git a/lib/aws_auth/authorization_header.ex b/lib/aws_auth/authorization_header.ex index 416615c..b108a69 100644 --- a/lib/aws_auth/authorization_header.ex +++ b/lib/aws_auth/authorization_header.ex @@ -18,7 +18,11 @@ defmodule AWSAuth.AuthorizationHeader do headers = Map.put_new(headers, "host", uri.host) - payload = AWSAuth.Utils.hash_sha256(payload) + payload = if payload == :hashed do + payload + else + AWSAuth.Utils.hash_sha256(payload) + end headers = Map.put_new(headers, "x-amz-content-sha256", payload) diff --git a/lib/aws_auth/utils.ex b/lib/aws_auth/utils.ex index bd188ce..e2387cb 100644 --- a/lib/aws_auth/utils.ex +++ b/lib/aws_auth/utils.ex @@ -13,9 +13,11 @@ defmodule AWSAuth.Utils do |> Enum.sort(&(&1 < &2)) |> Enum.join(";") - hashed_payload = if hashed_payload == :unsigned, - do: "UNSIGNED-PAYLOAD", - else: hashed_payload + hashed_payload = case hashed_payload do + :unsigned -> "UNSIGNED-PAYLOAD" + :hashed -> headers["x-amz-content-sha256"] + _ -> hashed_payload + end encoded_path = path