Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/apns.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
]},
{modules, []},
{mod, {apns_app, []}},
{env, [
{openssl_path, "openssl"}
]},
{maintainers,["Inaka"]},
{licenses,["Apache 2.0"]},
{links,[{"Github","https://github.com/inaka/apns4erl"}]},
Expand Down
4 changes: 3 additions & 1 deletion src/apns_utils.erl
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@
-spec sign(binary()) -> binary().
sign(Data) ->
{ok, KeyPath} = application:get_env(apns, token_keyfile),
{ok, Openssl} = application:get_env(apns, openssl_path),
Command = "printf '" ++
binary_to_list(Data) ++
"' | openssl dgst -binary -sha256 -sign " ++ KeyPath ++ " | base64",
"' | " ++ Openssl ++ " dgst -binary -sha256 -sign " ++ KeyPath ++ " | base64",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 41 is too long: "' | " ++ Openssl ++ " dgst -binary -sha256 -sign " ++ KeyPath ++ " | base64",.

{0, Result} = apns_os:cmd(Command),
strip_b64(list_to_binary(Result)).

Expand Down Expand Up @@ -67,3 +68,4 @@ seconds_to_timestamp(Secs) ->
-spec strip_b64(binary()) -> binary().
strip_b64(BS) ->
binary:list_to_bin(binary:split(BS, [<<"\n">>, <<"=">>], [global])).