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.
()
| 39 | /// (validation), so the gateway can round-trip its own tokens with no |
| 40 | /// further conversion. |
| 41 | pub 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 | /// |