1
0
mirror of https://github.com/pcvolkmer/cert-tools.git synced 2025-04-19 17:06:49 +00:00

feat: add copy to clipboard for cert fingerprints

This commit is contained in:
Paul-Christian Volkmer 2025-01-07 00:39:43 +01:00
parent b0ce06515d
commit 944e085a57

View File

@ -181,7 +181,7 @@ impl Ui {
}; };
Task::none() Task::none()
} }
Message::Copy => clipboard::write::<Message>(self.output.text()), Message::CopyValue(value) => clipboard::write::<Message>(value),
} }
} }
@ -297,7 +297,7 @@ impl Ui {
button("Copy to Clipboard").style(button::secondary) button("Copy to Clipboard").style(button::secondary)
} else { } else {
button("Copy to Clipboard") button("Copy to Clipboard")
.on_press(Message::Copy) .on_press(Message::CopyValue(self.output.text().trim().to_string()))
.style(button::secondary) .style(button::secondary)
}; };
let buttons = if self.cert_file.is_some() { let buttons = if self.cert_file.is_some() {
@ -342,7 +342,8 @@ impl Ui {
if let Some(chain) = &self.chain { if let Some(chain) = &self.chain {
for cert in chain.certs() { for cert in chain.certs() {
result = result.push( result = result.push(
Container::new(column![ Container::new(
column![
text(cert.name().to_string()).size(18), text(cert.name().to_string()).size(18),
horizontal_rule(1), horizontal_rule(1),
row![text("Issuer: ").width(200), text(cert.issuer().to_string())], row![text("Issuer: ").width(200), text(cert.issuer().to_string())],
@ -365,12 +366,28 @@ impl Ui {
], ],
row![ row![
text("SHA-1-Fingerprint: ").width(200), text("SHA-1-Fingerprint: ").width(200),
text(cert.fingerprint().sha1.to_string()) text(cert.fingerprint().sha1.to_string()),
], horizontal_space(),
button("Copy to Clipboard")
.style(button::secondary)
.padding(1)
.on_press(Message::CopyValue(
cert.fingerprint().sha1.to_string()
)),
]
.align_y(alignment::Vertical::Center),
row![ row![
text("SHA-256-Fingerprint: ").width(200), text("SHA-256-Fingerprint: ").width(200),
text(cert.fingerprint().sha256.to_string()) text(cert.fingerprint().sha256.to_string()),
], horizontal_space(),
button("Copy to Clipboard")
.style(button::secondary)
.padding(1)
.on_press(Message::CopyValue(
cert.fingerprint().sha1.to_string()
)),
]
.align_y(alignment::Vertical::Center),
row![ row![
text("Subject-Key-Id: ").width(200), text("Subject-Key-Id: ").width(200),
text(cert.subject_key_id().to_string()) text(cert.subject_key_id().to_string())
@ -387,7 +404,9 @@ impl Ui {
text(cert.dns_names().join(", ")) text(cert.dns_names().join(", "))
] ]
}, },
]) ]
.spacing(2),
)
.padding(8) .padding(8)
.style(|_| container::Style { .style(|_| container::Style {
background: Some(Background::Color(Color::WHITE)), background: Some(Background::Color(Color::WHITE)),
@ -721,7 +740,7 @@ enum Message {
SetKeyFile(Result<PathBuf, Error>), SetKeyFile(Result<PathBuf, Error>),
Print, Print,
Merge, Merge,
Copy, CopyValue(String),
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]