From 287479056ed001978eebe9af1fe269ae788f6e30 Mon Sep 17 00:00:00 2001 From: 5HT Date: Mon, 28 Oct 2024 23:09:31 +0200 Subject: [PATCH] EST server /ca /cacerts /csrattrs HTTP endpoints --- lib/services/est.ex | 1 + lib/services/http/delete.ex | 7 ------- lib/services/http/get.ex | 6 +++--- lib/services/http/patch.ex | 7 ------- lib/services/http/put.ex | 7 ------- 5 files changed, 4 insertions(+), 24 deletions(-) delete mode 100644 lib/services/http/delete.ex delete mode 100644 lib/services/http/patch.ex delete mode 100644 lib/services/http/put.ex diff --git a/lib/services/est.ex b/lib/services/est.ex index 88f9f33..0acbb60 100644 --- a/lib/services/est.ex +++ b/lib/services/est.ex @@ -23,6 +23,7 @@ defmodule CA.EST do get "/.well-known/est/ca" do CA.EST.Get.get(conn, [], "Authority", [], "CA") end get "/.well-known/est/cacerts" do CA.EST.Get.get(conn, [], "Authority", [], "CMS") end get "/.well-known/est/csrattrs" do CA.EST.Get.get(conn, [], "Authority", [], "ABAC") end + post "/.well-known/est/simpleenroll" do CA.EST.Post.post(conn, [], "Authority", [], "ENROLL") end post "/.well-known/est/simplereenroll" do CA.EST.Post.post(conn, [], "Authority", [], "RE-ENROLL") end post "/.well-known/est/serverkeygen" do CA.EST.Post.post(conn, [], "Authority", [], "KEYGEN") end diff --git a/lib/services/http/delete.ex b/lib/services/http/delete.ex deleted file mode 100644 index e7f137f..0000000 --- a/lib/services/http/delete.ex +++ /dev/null @@ -1,7 +0,0 @@ -defmodule CA.EST.Delete do - import Plug.Conn - def delete(conn,_,type,id,spec) do -# :io.format 'DELETE/3:#{type}#{id}/#{spec}', [] - send_resp(conn, 200, CA.EST.encode(%{"type" => type, "id" => id, "spec" => spec})) - end -end \ No newline at end of file diff --git a/lib/services/http/get.ex b/lib/services/http/get.ex index d4e32b5..d62bc02 100644 --- a/lib/services/http/get.ex +++ b/lib/services/http/get.ex @@ -5,7 +5,7 @@ defmodule CA.EST.Get do body = :base64.encode(CA.CSR.read_ca_public()) conn |> put_resp_content_type("application/pkix-cert") |> put_resp_header("Content-Transfer-Encoding", "base64") - |> put_resp_header("Content-Length", :erlang.integer_to_binary(:erlang.size(body))) + |> put_resp_header("Content-Length", Integer.to_string(byte_size(body))) |> resp(200, body) |> send_resp() end @@ -21,7 +21,7 @@ defmodule CA.EST.Get do body = :base64.encode cms conn |> put_resp_content_type("application/pkcs7-mime") |> put_resp_header("Content-Transfer-Encoding", "base64") - |> put_resp_header("Content-Length", :erlang.integer_to_binary(:erlang.size(body))) + |> put_resp_header("Content-Length", Integer.to_string(byte_size(body))) |> resp(200, body) |> send_resp() end @@ -30,7 +30,7 @@ defmodule CA.EST.Get do body = :base64.encode(CA.EST.csrattributes()) conn |> put_resp_content_type("application/csrattrs") |> put_resp_header("Content-Transfer-Encoding", "base64") - |> put_resp_header("Content-Length", :erlang.integer_to_binary(:erlang.size(body))) + |> put_resp_header("Content-Length", Integer.to_string(byte_size(body))) |> resp(200, body) |> send_resp() end diff --git a/lib/services/http/patch.ex b/lib/services/http/patch.ex deleted file mode 100644 index 068c7d4..0000000 --- a/lib/services/http/patch.ex +++ /dev/null @@ -1,7 +0,0 @@ -defmodule CA.EST.Patch do - import Plug.Conn - def patch(conn,_,type,id,spec) do -# :io.format 'PUT/4:#{type}#{id}/#{spec}', [] - send_resp(conn, 200, CA.EST.encode(%{"type" => type, "id" => id, "spec" => spec})) - end -end diff --git a/lib/services/http/put.ex b/lib/services/http/put.ex deleted file mode 100644 index ae0a005..0000000 --- a/lib/services/http/put.ex +++ /dev/null @@ -1,7 +0,0 @@ -defmodule CA.EST.Put do - import Plug.Conn - def put(conn,_,type,id,spec) do -# :io.format 'PUT/4:#{type}#{id}/#{spec}', [] - send_resp(conn, 200, CA.EST.encode(%{"type" => type, "id" => id, "spec" => spec})) - end -end