Skip to content

Commit cbd70c4

Browse files
authored
fix(rust/rbac-registration): CatalystId wrong subnet value for mainnet network (#444)
* fix catalyst_id subnet determination * bump crate version * fix clippy
1 parent 8b0b30f commit cbd70c4

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

rust/cardano-chain-follower/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cardano-chain-follower"
3-
version = "0.0.9"
3+
version = "0.0.10"
44
edition.workspace = true
55
authors.workspace = true
66
homepage.workspace = true

rust/rbac-registration/src/cardano/cip509/validation.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,13 +428,18 @@ fn validate_role_0(
428428

429429
let mut catalyst_id = None;
430430
let network = "cardano";
431+
// <https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/rbac_id_uri/catalyst-id-uri/#authority>
432+
let subnet = match subnet {
433+
Network::Mainnet => None,
434+
subnet => Some(subnet.to_string()),
435+
};
431436

432437
match signing_key.local_ref {
433438
LocalRefInt::X509Certs => {
434439
match metadata.x509_certs.first() {
435440
Some(X509DerCert::X509Cert(cert)) => {
436441
// All good: role 0 references a valid X509 certificate.
437-
catalyst_id = x509_cert_key(cert, context, report).map(|k| CatalystId::new(network, Some(&subnet.to_string()), k));
442+
catalyst_id = x509_cert_key(cert, context, report).map(|k| CatalystId::new(network, subnet.as_deref(), k));
438443
}
439444
Some(c) => report.other(&format!("Invalid X509 certificate value ({c:?}) for role 0 ({role:?})"), context),
440445
None => report.other("Role 0 reference X509 certificate at index 0, but there is no such certificate", context),
@@ -444,7 +449,7 @@ fn validate_role_0(
444449
match metadata.c509_certs.first() {
445450
Some(C509Cert::C509Certificate(cert)) => {
446451
// All good: role 0 references a valid C509 certificate.
447-
catalyst_id = c509_cert_key(cert, context, report).map(|k| CatalystId::new(network, Some(&subnet.to_string()), k));
452+
catalyst_id = c509_cert_key(cert, context, report).map(|k| CatalystId::new(network, subnet.as_deref(), k));
448453
}
449454
Some(c) => report.other(&format!("Invalid C509 certificate value ({c:?}) for role 0 ({role:?})"), context),
450455
None => report.other("Role 0 reference C509 certificate at index 0, but there is no such certificate", context),

0 commit comments

Comments
 (0)