mirror of
https://github.com/pcvolkmer/cert-tools.git
synced 2025-04-19 17:06:49 +00:00
chore: use monospace font
This commit is contained in:
parent
599b40e21a
commit
557ca5602d
@ -2,10 +2,9 @@
|
|||||||
|
|
||||||
use cert_tools::{Chain, PrivateKey};
|
use cert_tools::{Chain, PrivateKey};
|
||||||
use iced::border::Radius;
|
use iced::border::Radius;
|
||||||
use iced::widget::text::Shaping;
|
|
||||||
use iced::widget::text_editor::{default, Content, Status};
|
use iced::widget::text_editor::{default, Content, Status};
|
||||||
use iced::widget::{
|
use iced::widget::{
|
||||||
button, column, container, horizontal_rule, horizontal_space, row, text, text_editor,
|
self, button, column, container, horizontal_rule, horizontal_space, row, text, text_editor,
|
||||||
text_input, Container, Scrollable,
|
text_input, Container, Scrollable,
|
||||||
};
|
};
|
||||||
use iced::{
|
use iced::{
|
||||||
@ -23,7 +22,7 @@ fn main() -> iced::Result {
|
|||||||
..Settings::default()
|
..Settings::default()
|
||||||
})
|
})
|
||||||
.resizable(false)
|
.resizable(false)
|
||||||
.window_size(Size::new(1000.0, 800.0))
|
.window_size(Size::new(1020.0, 800.0))
|
||||||
.run_with(Ui::new)
|
.run_with(Ui::new)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,17 +255,17 @@ impl Ui {
|
|||||||
File::Invalid(_) => text_input(placeholder, &text),
|
File::Invalid(_) => text_input(placeholder, &text),
|
||||||
_ => text_input(placeholder, &text),
|
_ => text_input(placeholder, &text),
|
||||||
}
|
}
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
.style(move |theme, status| text_input::Style {
|
.style(move |theme, status| text_input::Style {
|
||||||
background: Background::Color(Color::WHITE),
|
background: Background::Color(Color::WHITE),
|
||||||
placeholder: color!(0x888888),
|
placeholder: color!(0x888888),
|
||||||
value: match file {
|
value: match file {
|
||||||
File::Certificates(_, _) | File::PrivateKey(_, _) => Color::BLACK,
|
File::Certificates(_, _) | File::PrivateKey(_, _) => Color::BLACK,
|
||||||
File::Invalid(_) => color!(0xaa0000),
|
File::Invalid(_) => color!(0xaa0000),
|
||||||
File::None => color!(0x888888),
|
File::None => color!(0x888888),
|
||||||
},
|
},
|
||||||
..text_input::default(theme, status)
|
..text_input::default(theme, status)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let cert_file_input = {
|
let cert_file_input = {
|
||||||
@ -285,7 +284,7 @@ impl Ui {
|
|||||||
.style(button::secondary)
|
.style(button::secondary)
|
||||||
]
|
]
|
||||||
.spacing(2)
|
.spacing(2)
|
||||||
.align_y(alignment::Vertical::Center)
|
.align_y(alignment::Vertical::Center)
|
||||||
};
|
};
|
||||||
|
|
||||||
let ca_file_input = {
|
let ca_file_input = {
|
||||||
@ -308,7 +307,7 @@ impl Ui {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
.spacing(2)
|
.spacing(2)
|
||||||
.align_y(alignment::Vertical::Center)
|
.align_y(alignment::Vertical::Center)
|
||||||
};
|
};
|
||||||
|
|
||||||
let key_file_input = {
|
let key_file_input = {
|
||||||
@ -331,7 +330,7 @@ impl Ui {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
.spacing(2)
|
.spacing(2)
|
||||||
.align_y(alignment::Vertical::Center)
|
.align_y(alignment::Vertical::Center)
|
||||||
};
|
};
|
||||||
|
|
||||||
let export_button = if !(self.chain_indicator_state == IndicatorState::Success
|
let export_button = if !(self.chain_indicator_state == IndicatorState::Success
|
||||||
@ -403,33 +402,38 @@ impl Ui {
|
|||||||
let mut result = column![];
|
let mut result = column![];
|
||||||
|
|
||||||
if let Some(chain) = &self.chain {
|
if let Some(chain) = &self.chain {
|
||||||
|
fn monospace_text<'a>(s: String) -> widget::Text<'a> {
|
||||||
|
text(s)
|
||||||
|
.shaping(text::Shaping::Advanced)
|
||||||
|
.font(Font::MONOSPACE)
|
||||||
|
.size(12)
|
||||||
|
}
|
||||||
|
|
||||||
for cert in chain.certs() {
|
for cert in chain.certs() {
|
||||||
result = result.push(
|
result = result.push(
|
||||||
Container::new(
|
Container::new(
|
||||||
column![
|
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(160), text(cert.issuer().to_string())],
|
||||||
row![
|
row![
|
||||||
text("Gültigkeit: ").width(200),
|
text("Gültigkeit: ").width(160),
|
||||||
text("Gültig von "),
|
text("Gültig von "),
|
||||||
if cert.is_valid_not_before(&SystemTime::now()) {
|
if cert.is_valid_not_before(&SystemTime::now()) {
|
||||||
text(cert.not_before().to_string())
|
text(cert.not_before().to_string())
|
||||||
} else {
|
} else {
|
||||||
text(cert.not_before().to_string())
|
text(cert.not_before().to_string()).color(color!(0xaa0000))
|
||||||
.color(color!(0xaa0000))
|
|
||||||
},
|
},
|
||||||
text(" bis "),
|
text(" bis "),
|
||||||
if cert.is_valid_not_after(&SystemTime::now()) {
|
if cert.is_valid_not_after(&SystemTime::now()) {
|
||||||
text(cert.not_after().to_string())
|
text(cert.not_after().to_string())
|
||||||
} else {
|
} else {
|
||||||
text(cert.not_after().to_string())
|
text(cert.not_after().to_string()).color(color!(0xaa0000))
|
||||||
.color(color!(0xaa0000))
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
row![
|
row![
|
||||||
text("SHA-1-Fingerprint: ").width(200),
|
text("SHA-1-Fingerprint: ").width(160),
|
||||||
text(cert.fingerprint().sha1.to_string()),
|
monospace_text(cert.fingerprint().sha1.to_string()),
|
||||||
horizontal_space(),
|
horizontal_space(),
|
||||||
button("Copy to Clipboard")
|
button("Copy to Clipboard")
|
||||||
.style(button::secondary)
|
.style(button::secondary)
|
||||||
@ -440,8 +444,8 @@ impl Ui {
|
|||||||
]
|
]
|
||||||
.align_y(alignment::Vertical::Center),
|
.align_y(alignment::Vertical::Center),
|
||||||
row![
|
row![
|
||||||
text("SHA-256-Fingerprint: ").width(200),
|
text("SHA-256-Fingerprint: ").width(160),
|
||||||
text(cert.fingerprint().sha256.to_string()),
|
monospace_text(cert.fingerprint().sha256.to_string()),
|
||||||
horizontal_space(),
|
horizontal_space(),
|
||||||
button("Copy to Clipboard")
|
button("Copy to Clipboard")
|
||||||
.style(button::secondary)
|
.style(button::secondary)
|
||||||
@ -452,30 +456,30 @@ impl Ui {
|
|||||||
]
|
]
|
||||||
.align_y(alignment::Vertical::Center),
|
.align_y(alignment::Vertical::Center),
|
||||||
row![
|
row![
|
||||||
text("Subject-Key-Id: ").width(200),
|
text("Subject-Key-Id: ").width(160),
|
||||||
text(cert.subject_key_id().to_string())
|
monospace_text(cert.subject_key_id().to_string())
|
||||||
],
|
],
|
||||||
row![
|
row![
|
||||||
text("Authority-Key-Id: ").width(200),
|
text("Authority-Key-Id: ").width(160),
|
||||||
text(cert.authority_key_id().to_string())
|
monospace_text(cert.authority_key_id().to_string())
|
||||||
],
|
],
|
||||||
if cert.dns_names().is_empty() {
|
if cert.dns_names().is_empty() {
|
||||||
row![]
|
row![]
|
||||||
} else {
|
} else {
|
||||||
row![
|
row![
|
||||||
text("DNS-Names: ").width(200),
|
text("DNS-Names: ").width(160),
|
||||||
text(cert.dns_names().join(", "))
|
text(cert.dns_names().join(", "))
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
.spacing(2),
|
.spacing(2),
|
||||||
)
|
)
|
||||||
.padding(8)
|
.padding(8)
|
||||||
.style(|_| container::Style {
|
.style(|_| container::Style {
|
||||||
background: Some(Background::Color(Color::WHITE)),
|
background: Some(Background::Color(Color::WHITE)),
|
||||||
..container::Style::default()
|
..container::Style::default()
|
||||||
})
|
})
|
||||||
.width(Length::Fill),
|
.width(Length::Fill),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -623,10 +627,10 @@ impl Ui {
|
|||||||
.center_x(160)
|
.center_x(160)
|
||||||
.center_y(40),
|
.center_y(40),
|
||||||
]
|
]
|
||||||
.spacing(4),
|
.spacing(4),
|
||||||
)
|
)
|
||||||
.center_x(160)
|
.center_x(160)
|
||||||
.center_y(80)
|
.center_y(80)
|
||||||
};
|
};
|
||||||
|
|
||||||
column![
|
column![
|
||||||
@ -828,7 +832,7 @@ async fn pick_file() -> Result<PathBuf, Error> {
|
|||||||
async fn export_file() -> Result<PathBuf, Error> {
|
async fn export_file() -> Result<PathBuf, Error> {
|
||||||
let path = rfd::AsyncFileDialog::new()
|
let path = rfd::AsyncFileDialog::new()
|
||||||
.set_title("Export file...")
|
.set_title("Export file...")
|
||||||
.add_filter("PEM-File", &["pem", "crt"])
|
.add_filter("PEM-File", &["crt", "pem"])
|
||||||
.save_file()
|
.save_file()
|
||||||
.await
|
.await
|
||||||
.ok_or(Error::Undefined)?;
|
.ok_or(Error::Undefined)?;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user