fix: harden signing key handling (#1166)
* fix: harden signing key handling * fix: validate static keys at compile time
This commit is contained in:
parent
38428f66bc
commit
d5c46b3fe0
1 changed files with 214 additions and 43 deletions
|
|
@ -594,11 +594,15 @@ async fn request_state_codec_seals_and_verifies_through_the_loop() -> anyhow::Re
|
|||
use rmcp::model::RequestStateCodec;
|
||||
|
||||
// A shared per-process signing key, mirroring how a real server would derive one.
|
||||
static KEY: &[u8] = b"integration-signing-key-32-bytes!";
|
||||
const KEY: &[u8] = b"integration-signing-key-32-bytes!";
|
||||
const _: () = assert!(
|
||||
KEY.len() >= RequestStateCodec::MIN_KEY_LENGTH,
|
||||
"KEY is shorter than RequestStateCodec::MIN_KEY_LENGTH",
|
||||
);
|
||||
|
||||
fn codec() -> &'static RequestStateCodec {
|
||||
static CODEC: OnceLock<RequestStateCodec> = OnceLock::new();
|
||||
CODEC.get_or_init(|| RequestStateCodec::new(KEY))
|
||||
CODEC.get_or_init(|| RequestStateCodec::new_unchecked(KEY))
|
||||
}
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
|
|
|
|||
Loading…
Reference in a new issue