diff options
-rw-r--r-- | src/sign.erl | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/sign.erl b/src/sign.erl index 07c5047..5949ad1 100644 --- a/src/sign.erl +++ b/src/sign.erl @@ -51,6 +51,7 @@ init([]) -> Port = open_port({spawn_executable, code:priv_dir(plop) ++ "/hsmhelper"}, [{args, Args}, + exit_status, {packet, 4}]), {ok, #state{pubkey = Public_key, hsmport = Port, @@ -234,6 +235,14 @@ handle_call({sign, Data}, _From, State) -> {Port, {data, RawSignature}} when is_port(Port) -> Signature = encode_ec_signature(list_to_binary(RawSignature), 256), lager:debug("received signing reply from HSM: ~p", [Signature]), - {reply, Signature, State} + {reply, Signature, State}; + {Port, {exit_status, ExitStatus}} -> + lager:error("hsmhelper port ~p exiting with status ~p", + [Port, ExitStatus]), + {stop, portexit, State} + after + 10000 -> + lager:error("HSM timeout"), + {stop, timeout, State} end end. |