@@ -201,9 +201,9 @@ validation_success_for_AMQP_client1(Config) ->
201201 % % Note that when this test is executed together with the HTTP provider group
202202 % % it runs into unexpected interference and fails, even if TLS app PEM cache is force
203203 % % cleared. That's why originally each group was made to use a separate node.
204- AuthorityInfo = { Root , _AuthorityKey } = erl_make_certs : make_cert ( []),
205- {Certificate , Key } = chain (AuthorityInfo ),
206- {Certificate2 , Key2 } = chain (AuthorityInfo ),
204+ RootCert = #{ cert : = Root } = public_key : pkix_test_root_cert ( " RootCA " , []),
205+ {Certificate , Key } = chain (RootCert ),
206+ {Certificate2 , Key2 } = chain (RootCert ),
207207 Port = port (Config ),
208208 Host = rabbit_ct_helpers :get_config (Config , rmq_hostname ),
209209 % % When: Rabbit accepts just this one authority's certificate
@@ -293,7 +293,7 @@ validate_chain1(Config) ->
293293 Port = port (Config ),
294294 Host = rabbit_ct_helpers :get_config (Config , rmq_hostname ),
295295
296- ok = whitelist (Config , " alice" , CertTrusted , KeyTrusted ),
296+ ok = whitelist (Config , " alice" , CertTrusted ),
297297 rabbit_trust_store :refresh (),
298298
299299 catch rabbit_networking :stop_tcp_listener (Port ),
@@ -326,18 +326,30 @@ validate_longer_chain1(Config) ->
326326 % % AND a certificate `CertUntrusted` that is not whitelisted with the same root as `CertTrusted`
327327 % % AND `CertInter` intermediate CA
328328 % % AND `RootTrusted` CA
329- AuthorityInfo = {RootCA , _AuthorityKey } = erl_make_certs :make_cert ([]),
330- Inter = {CertInter , {KindInter , KeyDataInter , _ }} = erl_make_certs :make_cert ([{issuer , AuthorityInfo }]),
331- KeyInter = {KindInter , KeyDataInter },
332- {CertUntrusted , {KindUntrusted , KeyDataUntrusted , _ }} = erl_make_certs :make_cert ([{issuer , Inter }]),
333- KeyUntrusted = {KindUntrusted , KeyDataUntrusted },
334- {CertTrusted , {Kind , KeyData , _ }} = erl_make_certs :make_cert ([{issuer , Inter }]),
335- KeyTrusted = {Kind , KeyData },
329+
330+ KeyInterDec = public_key :generate_key ({rsa , 2048 , 17 }),
331+ KeyInter = {'RSAPrivateKey' , public_key :der_encode ('RSAPrivateKey' , KeyInterDec )},
332+
333+ TestDataTrusted = public_key :pkix_test_data (#{
334+ root => [],
335+ intermediates => [[{key , KeyInterDec }]],
336+ peer => []
337+ }),
338+ CertTrusted = proplists :get_value (cert , TestDataTrusted ),
339+ KeyTrusted = proplists :get_value (key , TestDataTrusted ),
340+ [RootCA , CertInter , RootCA ] = proplists :get_value (cacerts , TestDataTrusted ),
341+
342+ TestDataUntrusted = public_key :pkix_test_data (#{
343+ root => #{cert => CertInter , key => KeyInterDec },
344+ peer => []
345+ }),
346+ CertUntrusted = proplists :get_value (cert , TestDataUntrusted ),
347+ KeyUntrusted = proplists :get_value (key , TestDataUntrusted ),
336348
337349 Port = port (Config ),
338350 Host = rabbit_ct_helpers :get_config (Config , rmq_hostname ),
339351
340- ok = whitelist (Config , " alice" , CertTrusted , KeyTrusted ),
352+ ok = whitelist (Config , " alice" , CertTrusted ),
341353 rabbit_trust_store :refresh (),
342354
343355 catch rabbit_networking :stop_tcp_listener (Port ),
@@ -486,7 +498,7 @@ whitelisted_certificate_accepted_from_AMQP_client_regardless_of_validation_to_ro
486498 Port = port (Config ),
487499 Host = rabbit_ct_helpers :get_config (Config , rmq_hostname ),
488500
489- ok = whitelist (Config , " alice" , CertTrusted , KeyTrusted ),
501+ ok = whitelist (Config , " alice" , CertTrusted ),
490502 rabbit_trust_store :refresh (),
491503
492504 % % When: Rabbit validates paths with a different root `R` than
@@ -520,7 +532,7 @@ removed_certificate_denied_from_AMQP_client1(Config) ->
520532
521533 Port = port (Config ),
522534 Host = rabbit_ct_helpers :get_config (Config , rmq_hostname ),
523- ok = whitelist (Config , " bob" , CertOther , KeyOther ),
535+ ok = whitelist (Config , " bob" , CertOther ),
524536 rabbit_trust_store :refresh (),
525537
526538 % % When: we wait for at least one second (the accuracy of the
@@ -584,7 +596,7 @@ installed_certificate_accepted_from_AMQP_client1(Config) ->
584596 {key , Key } | cfg ()], 1 , 1 ),
585597
586598 wait_for_file_system_time (),
587- ok = whitelist (Config , " charlie" , CertOther , KeyOther ),
599+ ok = whitelist (Config , " charlie" , CertOther ),
588600 wait_for_trust_store_refresh (),
589601
590602 % % Then: a client presenting the whitelisted certificate `CertOther`
@@ -618,8 +630,8 @@ whitelist_directory_DELTA1(Config) ->
618630 {_ , CertRevoked , KeyRevoked } = ct_helper :make_certs (),
619631 {_ , CertListed2 , KeyListed2 } = ct_helper :make_certs (),
620632
621- ok = whitelist (Config , " foo" , CertListed1 , KeyListed1 ),
622- ok = whitelist (Config , " bar" , CertRevoked , KeyRevoked ),
633+ ok = whitelist (Config , " foo" , CertListed1 ),
634+ ok = whitelist (Config , " bar" , CertRevoked ),
623635 rabbit_trust_store :refresh (),
624636
625637 % % When: we wait for at least one second (the accuracy
@@ -633,7 +645,7 @@ whitelist_directory_DELTA1(Config) ->
633645
634646 wait_for_file_system_time (),
635647 ok = delete (" bar.pem" , Config ),
636- ok = whitelist (Config , " baz" , CertListed2 , KeyListed2 ),
648+ ok = whitelist (Config , " baz" , CertListed2 ),
637649 wait_for_trust_store_refresh (),
638650
639651 % % Then: connectivity to Rabbit is as it should be.
@@ -695,7 +707,7 @@ replaced_whitelisted_certificate_should_be_accepted1(Config) ->
695707 {cert , Cert },
696708 {key , Key } | cfg ()], 1 , 1 ),
697709 % % And: the first certificate has been whitelisted
698- ok = whitelist (Config , " bart" , CertFirst , KeyFirst ),
710+ ok = whitelist (Config , " bart" , CertFirst ),
699711 rabbit_trust_store :refresh (),
700712
701713 wait_for_trust_store_refresh (),
@@ -732,7 +744,7 @@ replaced_whitelisted_certificate_should_be_accepted1(Config) ->
732744 ok = amqp_connection :close (Con ),
733745
734746 % % When: a whitelisted certicate is replaced with one with the same name
735- ok = whitelist (Config , " bart" , CertUpdated , KeyUpdated ),
747+ ok = whitelist (Config , " bart" , CertUpdated ),
736748
737749 wait_for_trust_store_refresh (),
738750
@@ -797,10 +809,10 @@ ignore_corrupt_cert1(Config) ->
797809 {_ , CertTrusted , KeyTrusted } = ct_helper :make_certs (),
798810
799811 rabbit_trust_store :refresh (),
800- ok = whitelist (Config , " alice" , CertTrusted , KeyTrusted ),
812+ ok = whitelist (Config , " alice" , CertTrusted ),
801813
802814 % % When: Rabbit tries to whitelist the corrupt certificate.
803- ok = whitelist (Config , " corrupt" , <<48 >>, KeyTrusted ),
815+ ok = whitelist (Config , " corrupt" , <<48 >>),
804816 rabbit_trust_store :refresh (),
805817
806818 catch rabbit_networking :stop_tcp_listener (Port ),
@@ -835,9 +847,9 @@ ignore_same_cert_with_different_name1(Config) ->
835847 {_ , CertTrusted , KeyTrusted } = ct_helper :make_certs (),
836848
837849 rabbit_trust_store :refresh (),
838- ok = whitelist (Config , " alice" , CertTrusted , KeyTrusted ),
850+ ok = whitelist (Config , " alice" , CertTrusted ),
839851 % % When: Rabbit tries to insert the duplicate certificate
840- ok = whitelist (Config , " malice" , CertTrusted , KeyTrusted ),
852+ ok = whitelist (Config , " malice" , CertTrusted ),
841853 rabbit_trust_store :refresh (),
842854
843855 catch rabbit_networking :stop_tcp_listener (Port ),
@@ -872,8 +884,8 @@ list(Config) ->
872884 ok = rabbit_ct_broker_helpers :rpc (Config , 0 , rabbit_trust_store , refresh , []),
873885 timer :sleep (2000 ),
874886
875- {_Root , Cert , Key } = ct_helper :make_certs (),
876- ok = whitelist (Config , " alice" , Cert , Key ),
887+ {_Root , Cert , _Key } = ct_helper :make_certs (),
888+ ok = whitelist (Config , " alice" , Cert ),
877889 % wait_for_trust_store_refresh(),
878890 ok = rabbit_ct_broker_helpers :rpc (Config , 0 , rabbit_trust_store , refresh , []),
879891 Certs = rabbit_ct_broker_helpers :rpc (Config , 0 ,
@@ -882,8 +894,8 @@ list(Config) ->
882894 {match , _ } = re :run (Certs , " .*alice\. pem.*" ).
883895
884896disabled_provider_removes_certificates (Config ) ->
885- {_Root , Cert , Key } = ct_helper :make_certs (),
886- ok = whitelist (Config , " alice" , Cert , Key ),
897+ {_Root , Cert , _Key } = ct_helper :make_certs (),
898+ ok = whitelist (Config , " alice" , Cert ),
887899 ok = rabbit_ct_broker_helpers :rpc (Config , 0 , rabbit_trust_store , refresh , []),
888900
889901 % % Certificate is there
@@ -902,8 +914,8 @@ disabled_provider_removes_certificates(Config) ->
902914 nomatch = re :run (CertsAfterDelete , " .*alice\. pem.*" ).
903915
904916enabled_provider_adds_cerificates (Config ) ->
905- {_Root , Cert , Key } = ct_helper :make_certs (),
906- ok = whitelist (Config , " alice" , Cert , Key ),
917+ {_Root , Cert , _Key } = ct_helper :make_certs (),
918+ ok = whitelist (Config , " alice" , Cert ),
907919 ok = rabbit_ct_broker_helpers :rpc (Config , 0 ,
908920 ? MODULE , change_configuration ,
909921 [rabbitmq_trust_store , [{directory , whitelist_dir (Config )},
@@ -949,9 +961,9 @@ cfg() ->
949961% % Ancillary
950962
951963chain (Issuer ) ->
952- % % Theses are DER encoded.
953- { Certificate , { Kind , Key , _ }} = erl_make_certs : make_cert ([{ issuer , Issuer }] ),
954- {Certificate , { Kind , Key } }.
964+ % % These are DER encoded.
965+ TestData = public_key : pkix_test_data (#{ root => Issuer , peer => [{ key , { rsa , 2048 , 17 }}]} ),
966+ {proplists : get_value ( cert , TestData ), proplists : get_value ( key , TestData ) }.
955967
956968change_configuration (App , Props ) ->
957969 ok = application :stop (App ),
@@ -964,10 +976,10 @@ change_cfg(App, [{Name,Value}|Rest]) ->
964976 ok = application :set_env (App , Name , Value ),
965977 change_cfg (App , Rest ).
966978
967- whitelist (Config , Filename , Certificate , { A , B } = _Key ) ->
979+ whitelist (Config , Filename , Certificate ) ->
968980 Path = whitelist_dir (Config ),
969- ok = erl_make_certs : write_pem ( Path , Filename , { Certificate , { A , B , not_encrypted }} ),
970- [ file : delete ( filename : join ( Path , K )) || K <- filelib : wildcard ( " *_key.pem " , Path )] ,
981+ ok = file : write_file ( filename : join ( Path , Filename ++ " .pem " ),
982+ public_key : pem_encode ([{ 'Certificate' , Certificate , not_encrypted }])) ,
971983 ok .
972984
973985delete (Name , Config ) ->
0 commit comments