mirror of
https://github.com/processone/ejabberd.git
synced 2025-01-01 17:53:00 +01:00
Handle the case when JWT key file contains JWK set
This commit is contained in:
parent
7eda35b945
commit
c7470f5107
@ -162,6 +162,8 @@ format_error({bad_cert, Why, Path}) ->
|
||||
format_error({bad_pem, Why, Path});
|
||||
format_error({bad_jwt_key, Path}) ->
|
||||
format("No valid JWT key found in file: ~ts", [Path]);
|
||||
format_error({bad_jwt_key_set, Path}) ->
|
||||
format("JWT key contains JWK set in file: ~ts", [Path]);
|
||||
format_error({bad_jid, Bad}) ->
|
||||
format("Invalid XMPP address: ~ts", [Bad]);
|
||||
format_error({bad_user, Bad}) ->
|
||||
|
@ -407,7 +407,15 @@ opt_type(jwt_key) ->
|
||||
{ok, Data} ->
|
||||
try jose_jwk:from_binary(Data) of
|
||||
{error, _} -> econf:fail({bad_jwt_key, Path});
|
||||
Ret -> Ret
|
||||
JWK ->
|
||||
case jose_jwk:to_map(JWK) of
|
||||
{_, #{<<"keys">> := [Key]}} ->
|
||||
jose_jwk:from_map(Key);
|
||||
{_, #{<<"keys">> := _}} ->
|
||||
econf:fail({bad_jwt_key_set, Path});
|
||||
_ ->
|
||||
JWK
|
||||
end
|
||||
catch _:_ ->
|
||||
econf:fail({bad_jwt_key, Path})
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user