diff --git a/lib/public_key/src/pubkey_cert.erl b/lib/public_key/src/pubkey_cert.erl index be47f651f904..d26b2b304cac 100644 --- a/lib/public_key/src/pubkey_cert.erl +++ b/lib/public_key/src/pubkey_cert.erl @@ -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} -> @@ -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) -> diff --git a/lib/public_key/test/public_key_SUITE.erl b/lib/public_key/test/public_key_SUITE.erl index 61b5a62a1971..e8338be52d7c 100644 --- a/lib/public_key/test/public_key_SUITE.erl +++ b/lib/public_key/test/public_key_SUITE.erl @@ -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, _} = @@ -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, []},