Skip to content

Commit

Permalink
Merge branch 'maint'
Browse files Browse the repository at this point in the history
  • Loading branch information
IngelaAndin committed Sep 25, 2024
2 parents 3eee815 + 5622413 commit 67db49f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/public_key/src/pubkey_cert.erl
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ verify_data(DerCert) ->
%% things with a validated certificate.
%% --------------------------------------------------------------------
verify_fun(#cert{der = DerCert, otp = OtpCert}, Result, UserState0, VerifyFun) ->
case apply_fun(VerifyFun, DerCert, OtpCert, Result, UserState0) of
case apply_fun(VerifyFun, OtpCert, DerCert, Result, UserState0) of
{valid, UserState} ->
UserState;
{valid_peer, UserState} ->
Expand Down Expand Up @@ -380,7 +380,7 @@ prepare_for_next_cert(Cert, #path_validation_state{
ValidationState = handle_inhibit_anypolicy(ValidationState2),
handle_last_cert(Cert, ValidationState).

apply_fun(Fun, DerCert, OtpCert, Result, UserState) ->
apply_fun(Fun, OtpCert, DerCert, Result, UserState) ->
if is_function(Fun, 4) ->
Fun(OtpCert, DerCert, Result, UserState);
is_function(Fun, 3) ->
Expand Down
19 changes: 10 additions & 9 deletions lib/public_key/test/public_key_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -924,15 +924,15 @@ pkix_path_validation(Config) when is_list(Config) ->
{error, {bad_cert,missing_basic_constraint}} =
public_key:pkix_path_validation(Trusted, [Cert1, Cert3,Cert4], []),

VerifyFunAndState0 = {fun(_,{bad_cert, missing_basic_constraint}, UserState) ->
VerifyFunAndState0 = {fun(#'OTPCertificate'{},{bad_cert, missing_basic_constraint}, UserState) ->
{valid, UserState};
(_,{bad_cert, _} = Reason, _) ->
(#'OTPCertificate'{},{bad_cert, _} = Reason, _) ->
{fail, Reason};
(_,{extension, _}, UserState) ->
(#'OTPCertificate'{},{extension, _}, UserState) ->
{unknown, UserState};
(_, valid, UserState) ->
(#'OTPCertificate'{}, valid, UserState) ->
{valid, UserState};
(_, valid_peer, UserState) ->
(#'OTPCertificate'{}, valid_peer, UserState) ->
{valid, UserState}
end, []},
{ok, _} =
Expand All @@ -942,14 +942,15 @@ pkix_path_validation(Config) when is_list(Config) ->
{error, {bad_cert, unknown_ca}} =
public_key:pkix_path_validation(unknown_ca, [Cert1, Cert3, Cert4], []),

%% Verify verify_fun/4
VerifyFunAndState1 =
{fun(_,{bad_cert, unknown_ca}, UserState) ->
{fun(#'OTPCertificate'{}, Der, {bad_cert, unknown_ca}, UserState) when is_binary(Der) ->
{valid, UserState};
(_,{bad_cert, _} = Reason, _) ->
(#'OTPCertificate'{}, Der, {bad_cert, _} = Reason, _) when is_binary(Der) ->
{fail, Reason};
(_,{extension, _}, UserState) ->
(#'OTPCertificate'{}, Der, {extension, _}, UserState) when is_binary(Der) ->
{unknown, UserState};
(_, valid, UserState) ->
(#'OTPCertificate'{}, Der, valid, UserState) when is_binary(Der) ->
{valid, UserState}
end, []},

Expand Down

0 comments on commit 67db49f

Please sign in to comment.