From 80ec611dc66cc656d6d9bf5d6196858c493bf25d Mon Sep 17 00:00:00 2001 From: Jake Morrison Date: Wed, 27 Dec 2023 15:04:33 -0600 Subject: [PATCH] Comment out WIP --- lib/acme_client/crypto.ex | 64 +++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/lib/acme_client/crypto.ex b/lib/acme_client/crypto.ex index 7b34f5b..82720e5 100644 --- a/lib/acme_client/crypto.ex +++ b/lib/acme_client/crypto.ex @@ -91,7 +91,7 @@ defmodule AcmeClient.Crypto do end end - defp parse_validity({:Validity, {:utcTime, not_before}, {:utcTime, not_after}}) do + def parse_validity({:Validity, {:utcTime, not_before}, {:utcTime, not_after}}) do {:ok, {utctime_to_iso8601(not_before), utctime_to_iso8601(not_after)}} end @@ -106,35 +106,35 @@ defmodule AcmeClient.Crypto do "20#{yy}-#{mo}-#{dd}T#{hh}:#{mm}:#{ss}Z" end - @spec make_cert_chain(binary(), binary(), binary()) :: [map()] - def make_cert_chain(domain, certificate, pkey) do - [cert | chain] = String.split(certificate, "\n\n") - - {entries, hashes} = Enum.reduce(chain, {[], []}, &get_cert_hash/2) - - cert = %{ - domain: domain, - cert: cert, - pkey: pkey, - chain: Enum.reverse(hashes) - } - - entries ++ [cert] - end - - defp get_cert_hash(content, {entries, hashes}) do - content = String.trim(content) - hash = :sha |> :crypto.hash(content) |> Base.encode16() - - case Repo.get(Cert, hash) do - nil -> - Logger.info("Adding chain cert: #{hash}") - - Repo.insert!(%Cert{hash: hash, content: content}) - {[%{domain: hash, cert: content} | entries], [hash | hashes]} - - %Cert{content: ^content} -> - {entries, [hash | hashes]} - end - end + # @spec make_cert_chain(binary(), binary(), binary()) :: [map()] + # def make_cert_chain(domain, certificate, pkey) do + # [cert | chain] = String.split(certificate, "\n\n") + # + # {entries, hashes} = Enum.reduce(chain, {[], []}, &get_cert_hash/2) + # + # cert = %{ + # domain: domain, + # cert: cert, + # pkey: pkey, + # chain: Enum.reverse(hashes) + # } + # + # entries ++ [cert] + # end + + # defp get_cert_hash(content, {entries, hashes}) do + # content = String.trim(content) + # hash = :sha |> :crypto.hash(content) |> Base.encode16() + # + # case Repo.get(Cert, hash) do + # nil -> + # Logger.info("Adding chain cert: #{hash}") + # + # Repo.insert!(%Cert{hash: hash, content: content}) + # {[%{domain: hash, cert: content} | entries], [hash | hashes]} + # + # %Cert{content: ^content} -> + # {entries, [hash | hashes]} + # end + # end end