fix: use repaired version of jsonwebkey convert lib

This commit is contained in:
Matthieu Bessat 2025-06-03 19:20:06 +02:00
parent fe5e2dcd97
commit 7a19b5a138
3 changed files with 16 additions and 15 deletions

7
Cargo.lock generated
View file

@ -972,7 +972,7 @@ dependencies = [
"chrono",
"env_logger",
"fully_pub",
"jsonwebkey-convert",
"jsonwebkey-convert-repaired",
"jsonwebtoken",
"kernel",
"log",
@ -1247,8 +1247,9 @@ dependencies = [
]
[[package]]
name = "jsonwebkey-convert"
version = "0.3.0"
name = "jsonwebkey-convert-repaired"
version = "0.3.1"
source = "git+https://forge.lefuturiste.fr/rust-libs/jsonwebkey-rs-repaired.git?branch=master#0182bf0b83ebaf0a8c64c103422363f00a4fff7f"
dependencies = [
"base64 0.13.1",
"lazy_static",

View file

@ -43,16 +43,15 @@ argh = { workspace = true }
sqlx = { workspace = true }
uuid = { workspace = true }
url = { workspace = true }
# To work with key pair
pem = "3.0.4"
# For now, we test if it's viable, and later we will fork it to fix the build (cf. issue
# https://github.com/informationsea/jsonwebkey-rs#1 )
[dependencies.jsonwebkey-convert]
path = "/home/mbess/workspace/foss/rust_libs/jsonwebkey-rs/jsonwebkey-convert"
[dependencies.jsonwebkey-convert-repaired]
git = "https://forge.lefuturiste.fr/rust-libs/jsonwebkey-rs-repaired.git"
branch = "master"
features = ["simple_asn1", "pem"]
pem = "3.0.4"
[build-dependencies]
minijinja-embed = "2.3.1"

View file

@ -1,5 +1,7 @@
use jsonwebkey_convert::RSAPublicKey;
use jsonwebkey_convert::der::FromPem;
use std::str::FromStr;
use jsonwebkey_convert_repaired::RSAPublicKey;
use jsonwebkey_convert_repaired::der::FromPem;
use axum::{extract::State, response::IntoResponse, Json};
use fully_pub::fully_pub;
@ -33,12 +35,11 @@ pub async fn get_signing_public_keys(
State(app_state): State<AppState>,
) -> impl IntoResponse {
let pem_data = app_state.secrets.signing_keypair.0;
// extract modulus and exp number from ASN.1 encoded PCKS 1 package
let rsa_jwk = RSAPublicKey::from_pem(pem_data)
.expect("Expected to decode PEM public key");
dbg!(&rsa_jwk);
.expect("Failed to extract RSA public key from PEM");
Json(JWKs {
keys: vec![rsa_jwk]
}).into_response()