summaryrefslogtreecommitdiff
path: root/verifycert.erl
diff options
context:
space:
mode:
Diffstat (limited to 'verifycert.erl')
-rwxr-xr-xverifycert.erl39
1 files changed, 0 insertions, 39 deletions
diff --git a/verifycert.erl b/verifycert.erl
deleted file mode 100755
index 0db0051..0000000
--- a/verifycert.erl
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/usr/bin/env escript
-%% -*- erlang -*-
-%%! -pa lib/catlfish-0.8.0-dev.ez/catlfish-0.8.0-dev/ebin -pa lib/lager-2.1.1.ez/lager-2.1.1/ebin -pa lib/plop-0.8.0-dev.ez/plop-0.8.0-dev/ebin
-
-write_reply(Bin) ->
- Length = size(Bin),
- file:write(standard_io, <<Length:32, Bin/binary>>).
-
-verify(RootCerts, DBEntry) ->
- try
- case catlfish:verify_entry(tlv:decodelist(DBEntry), RootCerts) of
- {ok, _MTLHash} ->
- write_reply(<<0:8>>);
- {error, Reason} ->
- ReasonBin = list_to_binary(io_lib:format("~p", [Reason])),
- write_reply(<<1:8, ReasonBin/binary>>)
- end
- catch
- Type:What ->
- [CrashFunction | Stack] = erlang:get_stacktrace(),
- ErrorBin = list_to_binary(io_lib:format("Crash: ~p ~p~n~p~n~p~n", [Type, What, CrashFunction, Stack])),
- write_reply(<<2:8, ErrorBin/binary>>)
- end.
-
-loop(RootCerts) ->
- {ok, LengthBin} = file:read(standard_io, 4),
- <<Length:32>> = list_to_binary(LengthBin),
- case Length of
- 0 ->
- none;
- _ ->
- {ok, DBEntry} = file:read(standard_io, Length),
- verify(RootCerts, list_to_binary(DBEntry)),
- loop(RootCerts)
- end.
-
-main([KnownRoots]) ->
- Certs = x509:read_pemfiles_from_dir(KnownRoots),
- loop(Certs).