fix(license): allow CRLF in license keys
This commit is contained in:
parent
48b69bd60c
commit
7375bc5f9b
|
@ -85,8 +85,9 @@ max_connections(#{max_connections := MaxConns}) ->
|
||||||
%% Private functions
|
%% Private functions
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
|
|
||||||
do_parse(Content) ->
|
do_parse(Content0) ->
|
||||||
try
|
try
|
||||||
|
Content = trim(Content0),
|
||||||
[EncodedPayload, EncodedSignature] = binary:split(Content, <<".">>),
|
[EncodedPayload, EncodedSignature] = binary:split(Content, <<".">>),
|
||||||
Payload = base64:decode(EncodedPayload),
|
Payload = base64:decode(EncodedPayload),
|
||||||
Signature = base64:decode(EncodedSignature),
|
Signature = base64:decode(EncodedSignature),
|
||||||
|
@ -96,6 +97,13 @@ do_parse(Content) ->
|
||||||
{error, bad_license_format}
|
{error, bad_license_format}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
trim(Bin) ->
|
||||||
|
trim(trim(Bin, $\n), $\r).
|
||||||
|
|
||||||
|
trim(Bin, C) ->
|
||||||
|
[OneValue] = lists:filter(fun(X) -> X =/= <<>> end, binary:split(Bin, <<C:8>>, [global])),
|
||||||
|
OneValue.
|
||||||
|
|
||||||
verify_signature(Payload, Signature, Key) ->
|
verify_signature(Payload, Signature, Key) ->
|
||||||
public_key:verify(Payload, ?DIGEST_TYPE, Signature, Key).
|
public_key:verify(Payload, ?DIGEST_TYPE, Signature, Key).
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue