diff --git a/src/apns.app.src b/src/apns.app.src index 0c3efec..5050d37 100644 --- a/src/apns.app.src +++ b/src/apns.app.src @@ -13,6 +13,9 @@ ]}, {modules, []}, {mod, {apns_app, []}}, + {env, [ + {openssl_command, "openssl"} + ]}, {maintainers,["Inaka"]}, {licenses,["Apache 2.0"]}, {links,[{"Github","https://github.com/inaka/apns4erl"}]}, diff --git a/src/apns_utils.erl b/src/apns_utils.erl index 4050cb9..65881d5 100644 --- a/src/apns_utils.erl +++ b/src/apns_utils.erl @@ -35,9 +35,10 @@ -spec sign(binary()) -> binary(). sign(Data) -> {ok, KeyPath} = application:get_env(apns, token_keyfile), - Command = "printf '" ++ - binary_to_list(Data) ++ - "' | openssl dgst -binary -sha256 -sign " ++ KeyPath ++ " | base64", + {ok, Openssl} = application:get_env(apns, openssl_command), + Command = "printf '" ++ binary_to_list(Data) ++ + "' | " ++ Openssl ++ " dgst -binary -sha256 -sign " ++ + KeyPath ++ " | base64", {0, Result} = apns_os:cmd(Command), strip_b64(list_to_binary(Result)). @@ -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])). +