uses keyagent now

This commit is contained in:
Moon Man 2024-08-24 22:54:30 +00:00
parent bf5c9046e2
commit a20dafacde
1 changed files with 1 additions and 5 deletions

View File

@ -3,10 +3,6 @@ defmodule HTTPSignature do
Implements RFC 9421 HTTP Signatures using the Digest header. Implements RFC 9421 HTTP Signatures using the Digest header.
""" """
@algo :sha256
# Load this securely in production
@key "secret_key"
@spec create_signature_header(map(), list(), String.t(), binary()) :: String.t() @spec create_signature_header(map(), list(), String.t(), binary()) :: String.t()
def create_signature_header(headers, include_headers, key_id, body) do def create_signature_header(headers, include_headers, key_id, body) do
digest = compute_digest(body) digest = compute_digest(body)
@ -42,7 +38,7 @@ defmodule HTTPSignature do
end end
defp sign(data) do defp sign(data) do
:crypto.hash(@algo, [@key, data]) :crypto.hash(:sha256, [Vonbraun.KeyAgent.get_private_key(), data])
|> Base.encode64() |> Base.encode64()
|> String.downcase() |> String.downcase()
end end