added key name to page

This commit is contained in:
JMARyA 2022-11-14 22:22:46 +01:00
parent 4ddadfdce9
commit 9b989745e0
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
2 changed files with 12 additions and 7 deletions

6
Cargo.lock generated
View file

@ -357,9 +357,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
version = "0.4.22"
version = "0.4.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1"
checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f"
dependencies = [
"iana-time-zone",
"js-sys",
@ -642,7 +642,7 @@ dependencies = [
[[package]]
name = "gnupg"
version = "0.1.0"
source = "git+https://git.hydrar.de/jmarya/gnupg-rs#e4de0dc5e0c8c3ec4829363cc09b50e8e8b104ef"
source = "git+https://git.hydrar.de/jmarya/gnupg-rs#c6938384d522b07c27a0f468e4f0fda737f3b12d"
[[package]]
name = "h2"

View file

@ -74,9 +74,12 @@ pub async fn public_key(r: HttpRequest) -> impl Responder {
if pages::func::is_browser(&r) {
let config: &web::Data<config::Config> = r.app_data().unwrap();
let host = format!("http://{}", pages::func::get_host(&r));
let key = std::io::read_to_string(std::fs::File::open("/config/pub.key").unwrap())
.unwrap()
.replace("\n", "<br>");
let key = std::io::read_to_string(std::fs::File::open("/config/pub.key").unwrap()).unwrap();
let pgp = gnupg::GnuPG::new().unwrap();
let key_name = pgp.import_key(&key).unwrap().name;
let key = key.replace("\n", "<br>");
let resp = format!(
r#"
<div class="container" style="margin-top: 25px">
@ -84,7 +87,9 @@ pub async fn public_key(r: HttpRequest) -> impl Responder {
<b>To Import: </b>
<span style="display: block;font-family: monospace,monospace;margin-top: 10px; font-size: 20px;overflow-wrap: break-word;">
curl -sL "{host}/public_key"|gpg --import</span>
</div></div>
</div>
<h4 class="container card" style="padding-top: 10px; padding-bottom: 10px; background: black; margin-bottom: 15px;"> {key_name} </h4>
</div>
<div class="container card bg-primary"><p> {key} </p></div>
"#
);