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

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>
"#
);