summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorUlf Wiger <ulf@feuerlabs.com>2015-08-20 16:28:49 +0200
committerUlf Wiger <ulf@feuerlabs.com>2015-11-20 13:41:50 -0800
commit45ddf112263c1cf583f04ec658f6b141ec3d0b00 (patch)
tree44f9e548c7c85ca6b206f870b0990a82351d2871 /components
parentb5cf44194c21241d2b16ac11857ef65f7cb34bdd (diff)
downloadrvi_core-45ddf112263c1cf583f04ec658f6b141ec3d0b00.tar.gz
ensure no trailing ws in cert files
Diffstat (limited to 'components')
-rw-r--r--components/authorize/src/author.erl7
1 files changed, 6 insertions, 1 deletions
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