MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / generate_jwt_key

Function generate_jwt_key

crates/openshell-bootstrap/src/jwt.rs:41–53  ·  view source on GitHub ↗

Generate a fresh Ed25519 JWT signing key. Output PEM is in the formats `jsonwebtoken` consumes via `EncodingKey::from_ed_pem` (signing) and `DecodingKey::from_ed_pem` (validation), so the gateway can round-trip its own tokens with no further conversion.

()

Source from the content-addressed store, hash-verified

39/// (validation), so the gateway can round-trip its own tokens with no
40/// further conversion.
41pub fn generate_jwt_key() -> Result<JwtKeyMaterial> {
42 let keypair = KeyPair::generate_for(&PKCS_ED25519)
43 .into_diagnostic()
44 .wrap_err("failed to generate Ed25519 JWT signing key")?;
45 let signing_key_pem = keypair.serialize_pem();
46 let public_key_pem = keypair.public_key_pem();
47 let kid = kid_from_public_key_der(&keypair.public_key_der());
48 Ok(JwtKeyMaterial {
49 signing_key_pem,
50 public_key_pem,
51 kid,
52 })
53}
54
55/// Stable `kid` derived from the SHA-256 of the public-key DER.
56///

Callers 6

generate_pkiFunction · 0.85
pair_with_ttlFunction · 0.85
state_with_issuerFunction · 0.85

Calls 1

kid_from_public_key_derFunction · 0.85

Tested by 2