From 11f4f36a689b6447c9898a2840418e581cb3eb11 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Tue, 28 Oct 2025 14:10:48 -0400 Subject: Use PKCS8 PEM, not raw SEC1 bytes, to store VAPID keys. The `web-push` crate's VAPID signing support requires a private key. The `p256` crate is more than capable of generating one, but the easiest way to get a key from a `p256::ecdsa::SigningKey` to a `web_push::PartialVapidSignature` is via PKCS #8 PEM, not via the bytes. Since we'll need it in that form anyways, store it that way, so that we don't have to decode it using `p256`, re-encode to PEM, then decode to `PartialVapidSignature`. The migration in this commit invalidates existing VAPID keys. We could include support for re-encoding them on read, but there's little point: this code is still in flux anyways, and only development deployments exist. By the time this is final, the schema will have settled. --- src/boot/app.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/boot') diff --git a/src/boot/app.rs b/src/boot/app.rs index 8da3e90..88255b0 100644 --- a/src/boot/app.rs +++ b/src/boot/app.rs @@ -78,6 +78,7 @@ pub enum Error { Database(#[from] sqlx::Error), Name(#[from] name::Error), Ecdsa(#[from] p256::ecdsa::Error), + Pkcs8(#[from] p256::pkcs8::Error), } impl From for Error { @@ -106,6 +107,7 @@ impl From for Error { match error { Error::Database(error) => error.into(), Error::Ecdsa(error) => error.into(), + Error::Pkcs8(error) => error.into(), } } } -- cgit v1.2.3