From 45ddf112263c1cf583f04ec658f6b141ec3d0b00 Mon Sep 17 00:00:00 2001 From: Ulf Wiger Date: Thu, 20 Aug 2015 16:28:49 +0200 Subject: ensure no trailing ws in cert files --- components/authorize/src/author.erl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'components') diff --git a/components/authorize/src/author.erl b/components/authorize/src/author.erl index 311e8b0..c158e44 100644 --- a/components/authorize/src/author.erl +++ b/components/authorize/src/author.erl @@ -76,7 +76,7 @@ cmd("read_sig", Opts) -> {_, Pub} = get_key_pair(Root), case file:read_file(Sig) of {ok, JWT} -> - case authorize_sig:decode_jwt(JWT, Pub) of + case authorize_sig:decode_jwt(strip_nl(JWT), Pub) of invalid -> fail("Cannot validate ~s~n", [Sig]); {Header, Payload} -> @@ -182,6 +182,11 @@ l2i(Str) -> i2l(I) -> integer_to_list(I). +strip_nl(Bin) -> + case re:split(Bin,"\\s+$",[{return,binary},trim]) of + [Trimmed] -> Trimmed; + _ -> Bin + end. make_auth(RPriv, Pub, Fmt, Opts) -> case Fmt of -- cgit v1.2.1