Skip to content

Commit

Permalink
update certs.dev task
Browse files Browse the repository at this point in the history
  • Loading branch information
kmakiela committed Sep 25, 2019
1 parent 105935b commit 5925e75
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/mix/tasks/certs_dev.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ defmodule Mix.Tasks.Certs.Dev do

@spec run(term) :: :ok
def run(_) do
maybe_gen_apns_token()
maybe_gen_dev_apns()
maybe_gen_prod_apns()
maybe_gen_https()
Expand Down Expand Up @@ -141,4 +142,26 @@ defmodule Mix.Tasks.Certs.Dev do
|> Tuple.to_list()
|> Enum.join(".")
end

defp maybe_gen_apns_token do
path = "priv/apns/token.p8"

if File.exists?(path) do
:ok
else
dir = Path.dirname(path)
:ok = File.mkdir_p(dir)
:ok = gen_apns_token(path)
end
end

defp gen_apns_token(path) do
{_, 0} =
System.cmd(
"openssl",
["ecparam", "-name", "prime256v1", "-genkey", "-noout", "-out", path]
)

:ok
end
end

0 comments on commit 5925e75

Please sign in to comment.