summaryrefslogtreecommitdiff
path: root/src/dnssecport.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/dnssecport.erl')
-rw-r--r--src/dnssecport.erl15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/dnssecport.erl b/src/dnssecport.erl
index 30c8c9e..acdc5c4 100644
--- a/src/dnssecport.erl
+++ b/src/dnssecport.erl
@@ -23,9 +23,16 @@ validate(Data) ->
-record(state, {port :: port()}).
+-spec trust_anchors() -> string().
+trust_anchors() ->
+ case application:get_env(catlfish, trust_anchors_file) of
+ {ok, Filename} -> Filename;
+ undefined -> []
+ end.
+
init(Program) ->
lager:debug("starting dnssec service"),
- Port = create_port(Program, []), % TODO: Pass path to trust root file.
+ Port = create_port(Program, [trust_anchors()]),
{ok, #state{port = Port}}.
decode_response(Response) ->
@@ -38,9 +45,9 @@ handle_call(stop, _From, State) ->
handle_call({validate, Data}, _From, State) ->
case State#state.port of
undefined ->
- {error, noport};
+ {reply, {error, noport}, State};
Port when is_port(Port) ->
- Port ! {self(), {command, dns:encode_rrset(Data)}},
+ Port ! {self(), {command, Data}},
receive
{Port, {data, Response}} ->
case decode_response(list_to_binary(Response)) of
@@ -50,6 +57,8 @@ handle_call({validate, Data}, _From, State) ->
dns:encode_rrset(Chain)],
{reply, {ok, R}, State};
{ok, Error, _} ->
+ lager:debug("DNSSEC validation failed with ~p",
+ [Error]),
{reply, {error, Error}, State}
end;
{Port, {exit_status, ExitStatus}} ->