log info about generated jwt key

This commit is contained in:
Robin Appelman 2026-11-04 15:23:28 +01:00
commit 905c240037
Signed by: robin
SSH key fingerprint: SHA256:kifqgrqnut7q1YUIrI0AdMNC23qiKAS/T9uGFmIYvbE

View file

@ -1,8 +1,9 @@
use crate::error::{ConfigError, JwtError};
use jsonwebtoken::EncodingKey;
use rsa::pkcs8::EncodePrivateKey;
use jsonwebtoken::jwk::{Jwk, ThumbprintHash};
use jsonwebtoken::{Algorithm, EncodingKey};
use rsa::RsaPrivateKey;
use secretfile::{load, SecretError};
use rsa::pkcs8::EncodePrivateKey;
use secretfile::{SecretError, load};
use serde::de::Error;
use serde::{Deserialize, Deserializer};
use serde_json::Value;
@ -12,6 +13,7 @@ use std::fs::read_to_string;
use std::net::IpAddr;
use std::path::{Path, PathBuf};
use std::time::Duration;
use tracing::info;
#[derive(Debug, Deserialize)]
pub struct Config {
@ -70,7 +72,11 @@ impl TryFrom<JwtConfigRaw> for JwtConfig {
None => {
let mut rng = rand::rng();
let key = RsaPrivateKey::new(&mut rng, 4096)?.to_pkcs8_der()?;
EncodingKey::from_rsa_der(key.as_bytes())
let key = EncodingKey::from_rsa_der(key.as_bytes());
let jwk = Jwk::from_encoding_key(&key, Algorithm::RS256)?;
let key_id = jwk.thumbprint(ThumbprintHash::SHA256)?;
info!(kid = key_id, "generated new RS256 key");
key
}
};