SignedPacket::from_packet fails to encode a cname that references the same public key that it is signed with. I am clueless why it does not work. The error message DnsError(InsufficientData) is not hinting to the problem at all.
called `Result::unwrap()` on an `Err` value: DnsError(InsufficientData)
stack backtrace:
0: rust_begin_unwind
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:645:5
1: core::panicking::panic_fmt
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:72:14
2: core::result::unwrap_failed
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/result.rs:1653:5
3: core::result::Result<T,E>::unwrap
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/result.rs:1077:23
4: pknamescli::commands::pkarr::pkarr_records::tests::parse_spacefil2e
at ./src/commands/pkarr/pkarr_records.rs:281:22
5: pknamescli::commands::pkarr::pkarr_records::tests::parse_spacefil2e::{{closure}}
at ./src/commands/pkarr/pkarr_records.rs:267:26
6: core::ops::function::FnOnce::call_once
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:250:5
7: core::ops::function::FnOnce::call_once
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:250:5
How to reproduce
#[cfg(test)]
mod tests {
use pkarr::{dns::{rdata::RData, Name, Packet, ResourceRecord}, Keypair, SignedPacket};
#[test]
fn build_signed_packet_with_cname() {
let keypair = Keypair::random();
let pubkey = keypair.to_z32();
let name = Name::new("www.pknames.p2p").unwrap();
let data = format!("pknames.p2p.{pubkey}");
let data = Name::new(&data).unwrap();
let rdata = RData::CNAME(pkarr::dns::rdata::CNAME(data));
let record = ResourceRecord::new(name, pkarr::dns::CLASS::IN, 5000, rdata);
let mut packet = Packet::new_reply(0);
packet.answers = vec![record];
let signed = SignedPacket::from_packet(&keypair, &packet).unwrap();
}
}
What to expect
Should parse as usual or maybe throw a better error message?
Bug Report
SignedPacket::from_packet
fails to encode a cname that references the same public key that it is signed with. I am clueless why it does not work. The error messageDnsError(InsufficientData)
is not hinting to the problem at all.How to reproduce
What to expect
Should parse as usual or maybe throw a better error message?