Skip to content

Commit

Permalink
Make encoding errors of known extensions handable by the verify_fun
Browse files Browse the repository at this point in the history
  • Loading branch information
IngelaAndin committed Nov 11, 2022
1 parent aba5ad6 commit 44cdc54
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/public_key/src/pubkey_cert_records.erl
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,17 @@ decode_extensions(asn1_NOVALUE) ->
decode_extensions(Exts) ->
lists:map(fun(Ext = #'Extension'{extnID=Id, extnValue=Value0}) ->
case extension_id(Id) of
undefined -> Ext;
undefined ->
Ext;
Type ->
{ok, Value} = 'OTP-PUB-KEY':decode(Type, iolist_to_binary(Value0)),
Ext#'Extension'{extnValue=transform(Value,decode)}
end
end, Exts).
case 'OTP-PUB-KEY':decode(Type, iolist_to_binary(Value0)) of

This comment has been minimized.

Copy link
@andreasanta

andreasanta Nov 21, 2022

@IngelaAndin I think that this throws and error, so I would replace case with try, if you agree.

This way the caller can intercept the malformed extension and decide what to do with it. What do you think?

{ok, Value} ->
Ext#'Extension'{extnValue=transform(Value,decode)};
_ ->
Ext
end
end
end, Exts).

encode_extensions(asn1_NOVALUE) ->
asn1_NOVALUE;
Expand Down

0 comments on commit 44cdc54

Please sign in to comment.