File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
rust/rbac-registration/src/cardano/cip509 Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -176,16 +176,23 @@ fn extract_stake_addresses(uris: Option<&Cip0134UriSet>) -> Vec<VKeyHash> {
176176}
177177
178178/// Checks that only role 0 uses certificates with zero index.
179+ #[ allow( clippy:: similar_names) ]
179180pub fn validate_role_data ( metadata : & Cip509RbacMetadata , report : & ProblemReport ) {
180181 let context = "Role data validation" ;
181182
182- if matches ! (
183+ let has_x_0_cert = matches ! ( metadata. x509_certs. first( ) , Some ( X509DerCert :: X509Cert ( _) ) ) ;
184+ let has_c_0_cert = matches ! (
183185 metadata. c509_certs. first( ) ,
184186 Some ( C509Cert :: C509Certificate ( _) )
185- ) && matches ! ( metadata. x509_certs. first( ) , Some ( X509DerCert :: X509Cert ( _) ) )
186- {
187+ ) ;
188+ // There should be only one role 0 certificate.
189+ if has_x_0_cert && has_c_0_cert {
187190 report. other ( "Only one certificate can be defined at index 0" , context) ;
188191 }
192+ // Only role 0 can contain certificates at 0 index.
193+ if !metadata. role_data . contains_key ( & RoleNumber :: ROLE_0 ) && ( has_x_0_cert || has_c_0_cert) {
194+ report. other ( "Only role 0 can contain certificates at index 0" , context) ;
195+ }
189196
190197 for ( number, data) in & metadata. role_data {
191198 if number == & RoleNumber :: ROLE_0 {
You can’t perform that action at this time.
0 commit comments