@@ -201,9 +201,9 @@ validation_success_for_AMQP_client1(Config) ->
201
201
% % Note that when this test is executed together with the HTTP provider group
202
202
% % it runs into unexpected interference and fails, even if TLS app PEM cache is force
203
203
% % 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 ),
207
207
Port = port (Config ),
208
208
Host = rabbit_ct_helpers :get_config (Config , rmq_hostname ),
209
209
% % When: Rabbit accepts just this one authority's certificate
@@ -293,7 +293,7 @@ validate_chain1(Config) ->
293
293
Port = port (Config ),
294
294
Host = rabbit_ct_helpers :get_config (Config , rmq_hostname ),
295
295
296
- ok = whitelist (Config , " alice" , CertTrusted , KeyTrusted ),
296
+ ok = whitelist (Config , " alice" , CertTrusted ),
297
297
rabbit_trust_store :refresh (),
298
298
299
299
catch rabbit_networking :stop_tcp_listener (Port ),
@@ -326,18 +326,30 @@ validate_longer_chain1(Config) ->
326
326
% % AND a certificate `CertUntrusted` that is not whitelisted with the same root as `CertTrusted`
327
327
% % AND `CertInter` intermediate CA
328
328
% % 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 ),
336
348
337
349
Port = port (Config ),
338
350
Host = rabbit_ct_helpers :get_config (Config , rmq_hostname ),
339
351
340
- ok = whitelist (Config , " alice" , CertTrusted , KeyTrusted ),
352
+ ok = whitelist (Config , " alice" , CertTrusted ),
341
353
rabbit_trust_store :refresh (),
342
354
343
355
catch rabbit_networking :stop_tcp_listener (Port ),
@@ -486,7 +498,7 @@ whitelisted_certificate_accepted_from_AMQP_client_regardless_of_validation_to_ro
486
498
Port = port (Config ),
487
499
Host = rabbit_ct_helpers :get_config (Config , rmq_hostname ),
488
500
489
- ok = whitelist (Config , " alice" , CertTrusted , KeyTrusted ),
501
+ ok = whitelist (Config , " alice" , CertTrusted ),
490
502
rabbit_trust_store :refresh (),
491
503
492
504
% % When: Rabbit validates paths with a different root `R` than
@@ -520,7 +532,7 @@ removed_certificate_denied_from_AMQP_client1(Config) ->
520
532
521
533
Port = port (Config ),
522
534
Host = rabbit_ct_helpers :get_config (Config , rmq_hostname ),
523
- ok = whitelist (Config , " bob" , CertOther , KeyOther ),
535
+ ok = whitelist (Config , " bob" , CertOther ),
524
536
rabbit_trust_store :refresh (),
525
537
526
538
% % When: we wait for at least one second (the accuracy of the
@@ -584,7 +596,7 @@ installed_certificate_accepted_from_AMQP_client1(Config) ->
584
596
{key , Key } | cfg ()], 1 , 1 ),
585
597
586
598
wait_for_file_system_time (),
587
- ok = whitelist (Config , " charlie" , CertOther , KeyOther ),
599
+ ok = whitelist (Config , " charlie" , CertOther ),
588
600
wait_for_trust_store_refresh (),
589
601
590
602
% % Then: a client presenting the whitelisted certificate `CertOther`
@@ -618,8 +630,8 @@ whitelist_directory_DELTA1(Config) ->
618
630
{_ , CertRevoked , KeyRevoked } = ct_helper :make_certs (),
619
631
{_ , CertListed2 , KeyListed2 } = ct_helper :make_certs (),
620
632
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 ),
623
635
rabbit_trust_store :refresh (),
624
636
625
637
% % When: we wait for at least one second (the accuracy
@@ -633,7 +645,7 @@ whitelist_directory_DELTA1(Config) ->
633
645
634
646
wait_for_file_system_time (),
635
647
ok = delete (" bar.pem" , Config ),
636
- ok = whitelist (Config , " baz" , CertListed2 , KeyListed2 ),
648
+ ok = whitelist (Config , " baz" , CertListed2 ),
637
649
wait_for_trust_store_refresh (),
638
650
639
651
% % Then: connectivity to Rabbit is as it should be.
@@ -695,7 +707,7 @@ replaced_whitelisted_certificate_should_be_accepted1(Config) ->
695
707
{cert , Cert },
696
708
{key , Key } | cfg ()], 1 , 1 ),
697
709
% % And: the first certificate has been whitelisted
698
- ok = whitelist (Config , " bart" , CertFirst , KeyFirst ),
710
+ ok = whitelist (Config , " bart" , CertFirst ),
699
711
rabbit_trust_store :refresh (),
700
712
701
713
wait_for_trust_store_refresh (),
@@ -732,7 +744,7 @@ replaced_whitelisted_certificate_should_be_accepted1(Config) ->
732
744
ok = amqp_connection :close (Con ),
733
745
734
746
% % 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 ),
736
748
737
749
wait_for_trust_store_refresh (),
738
750
@@ -797,10 +809,10 @@ ignore_corrupt_cert1(Config) ->
797
809
{_ , CertTrusted , KeyTrusted } = ct_helper :make_certs (),
798
810
799
811
rabbit_trust_store :refresh (),
800
- ok = whitelist (Config , " alice" , CertTrusted , KeyTrusted ),
812
+ ok = whitelist (Config , " alice" , CertTrusted ),
801
813
802
814
% % When: Rabbit tries to whitelist the corrupt certificate.
803
- ok = whitelist (Config , " corrupt" , <<48 >>, KeyTrusted ),
815
+ ok = whitelist (Config , " corrupt" , <<48 >>),
804
816
rabbit_trust_store :refresh (),
805
817
806
818
catch rabbit_networking :stop_tcp_listener (Port ),
@@ -835,9 +847,9 @@ ignore_same_cert_with_different_name1(Config) ->
835
847
{_ , CertTrusted , KeyTrusted } = ct_helper :make_certs (),
836
848
837
849
rabbit_trust_store :refresh (),
838
- ok = whitelist (Config , " alice" , CertTrusted , KeyTrusted ),
850
+ ok = whitelist (Config , " alice" , CertTrusted ),
839
851
% % When: Rabbit tries to insert the duplicate certificate
840
- ok = whitelist (Config , " malice" , CertTrusted , KeyTrusted ),
852
+ ok = whitelist (Config , " malice" , CertTrusted ),
841
853
rabbit_trust_store :refresh (),
842
854
843
855
catch rabbit_networking :stop_tcp_listener (Port ),
@@ -872,8 +884,8 @@ list(Config) ->
872
884
ok = rabbit_ct_broker_helpers :rpc (Config , 0 , rabbit_trust_store , refresh , []),
873
885
timer :sleep (2000 ),
874
886
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 ),
877
889
% wait_for_trust_store_refresh(),
878
890
ok = rabbit_ct_broker_helpers :rpc (Config , 0 , rabbit_trust_store , refresh , []),
879
891
Certs = rabbit_ct_broker_helpers :rpc (Config , 0 ,
@@ -882,8 +894,8 @@ list(Config) ->
882
894
{match , _ } = re :run (Certs , " .*alice\. pem.*" ).
883
895
884
896
disabled_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 ),
887
899
ok = rabbit_ct_broker_helpers :rpc (Config , 0 , rabbit_trust_store , refresh , []),
888
900
889
901
% % Certificate is there
@@ -902,8 +914,8 @@ disabled_provider_removes_certificates(Config) ->
902
914
nomatch = re :run (CertsAfterDelete , " .*alice\. pem.*" ).
903
915
904
916
enabled_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 ),
907
919
ok = rabbit_ct_broker_helpers :rpc (Config , 0 ,
908
920
? MODULE , change_configuration ,
909
921
[rabbitmq_trust_store , [{directory , whitelist_dir (Config )},
@@ -949,9 +961,9 @@ cfg() ->
949
961
% % Ancillary
950
962
951
963
chain (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 ) }.
955
967
956
968
change_configuration (App , Props ) ->
957
969
ok = application :stop (App ),
@@ -964,10 +976,10 @@ change_cfg(App, [{Name,Value}|Rest]) ->
964
976
ok = application :set_env (App , Name , Value ),
965
977
change_cfg (App , Rest ).
966
978
967
- whitelist (Config , Filename , Certificate , { A , B } = _Key ) ->
979
+ whitelist (Config , Filename , Certificate ) ->
968
980
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 }])) ,
971
983
ok .
972
984
973
985
delete (Name , Config ) ->
0 commit comments