Skip to content

Commit

Permalink
5.10.4
Browse files Browse the repository at this point in the history
  • Loading branch information
5HT committed Oct 28, 2024
1 parent 18894e4 commit 5d8a17f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
10 changes: 10 additions & 0 deletions lib/services/csr.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ defmodule CA.CSR do
{ca_key, ca}
end

def read_ca_public() do
{:ok, ca_bin} = :file.read_file "ca.pem"
list = String.split(ca_bin, "\n", trim: true)
list = :lists.reverse(tl(:lists.reverse(tl(list))))
bin = :base64.decode(:erlang.iolist_to_binary(list))
:io.format '~p~n', [:asn1rt_nif.decode_ber_tlv bin]
{:ok, _cader} = :"DSTU-Cert".decode(:Certificate, bin)

Check warning on line 31 in lib/services/csr.ex

View workflow job for this annotation

GitHub Actions / build

:"DSTU-Cert".decode/2 is undefined (module :"DSTU-Cert" is not available or is yet to be defined)
bin
end

def server(name) do
{ca_key, ca} = read_ca()
dn = "/C=UA/L=Київ/O=SYNRC/CN=" <> name
Expand Down
8 changes: 8 additions & 0 deletions lib/services/http/get.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
defmodule CA.EST.Get do
import Plug.Conn
def get(conn, [], "Authority", [], "ROOT") do
body = :base64.encode(CA.CSR.read_ca_public())
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)))
|> resp(200, body)
|> send_resp()
end
def get(conn, [], "Authority", [], "ABAC") do
body = :base64.encode(CA.EST.csrattributes())
conn |> put_resp_content_type("application/csrattrs")
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule CA.Mixfile do
def project() do
[
app: :ca,
version: "5.10.3",
version: "5.10.4",
description: "CA CXC 138 21 Certificate Authority",
package: [
name: :ca,
Expand Down
6 changes: 0 additions & 6 deletions priv/kep/DSTU-Cert.asn1
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ DirectoryString ::= CHOICE {

id-at OBJECT IDENTIFIER ::= {joint-iso-ccitt (2) ds (5) 4}

AlgorithmIdentifier ::= SEQUENCE {
algorithm OBJECT IDENTIFIER,
parameters ANY }
-- DEFINED BY algorithm OPTIONAL


Validity ::= SEQUENCE {
notBefore Time,
notAfter Time}
Expand Down

0 comments on commit 5d8a17f

Please sign in to comment.