summaryrefslogtreecommitdiff
path: root/src/v1.erl
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordu.net>2015-09-26 21:14:38 +0200
committerLinus Nordberg <linus@nordu.net>2015-11-13 17:02:23 +0100
commit6a3ca9771919c494685e898f947b9ca05ee866a1 (patch)
treee91b3f09d8971a9e26556488dcb7587ccec0e258 /src/v1.erl
parent35e92d56f1d6085c2fc413adaf8189d55c62cab5 (diff)
Base64-decode submitted blobs and treat them as leaf certs.
Diffstat (limited to 'src/v1.erl')
-rw-r--r--src/v1.erl10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/v1.erl b/src/v1.erl
index eb35ee7..40e93f2 100644
--- a/src/v1.erl
+++ b/src/v1.erl
@@ -153,6 +153,12 @@ add_blob(Input) ->
{error, E} ->
err400("add-blob: bad input:", E);
{struct, [{<<"blob">>, Blob}]} ->
- success(catlfish:add_chain(Blob, normal));
- _ -> err400("add-blob: missing input: blob", Input)
+ case (catch base64:decode(Blob)) of
+ {'EXIT', _} ->
+ err400("add-blob: invalid base64-encoded blob", Blob);
+ DecodedBlob ->
+ success(catlfish:add_chain(DecodedBlob, [], normal))
+ end;
+ _ ->
+ err400("add-blob: missing input: blob", Input)
end.