Skip to content

Commit a2e4e69

Browse files
committed
Fix VAPID key encoding issue
1 parent 754b9bf commit a2e4e69

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

coordinator/src/db.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use chrono::{DateTime, Utc};
88
use serde::{Deserialize, Serialize};
99
use sqlx::{Sqlite, SqlitePool, migrate::MigrateDatabase};
1010

11-
use base64::{Engine as _, engine::general_purpose::STANDARD as BASE64};
11+
use base64::{Engine as _, engine::general_purpose};
1212

1313
use crate::http::m2m::{LeaseMap, LeaseSource};
1414

@@ -412,11 +412,9 @@ pub async fn get_or_generate_vapid_keys(pool: &DbPool) -> eyre::Result<VapidKeys
412412
let key_pair = rcgen::KeyPair::generate()?;
413413
let private_key_pem = key_pair.serialize_pem();
414414

415-
// For VAPID, we need the public key in uncompressed format
416-
// But for simplicity, let's store both PEM and compute public key later
417415
let private_key = private_key_pem;
418-
let public_key_pem = key_pair.public_key_pem();
419-
let public_key = BASE64.encode(public_key_pem.as_bytes());
416+
let public_key_raw = key_pair.public_key_raw();
417+
let public_key = general_purpose::URL_SAFE_NO_PAD.encode(&public_key_raw);
420418

421419
store_kv(pool, KV_VAPID_PRIVATE_KEY, &private_key).await?;
422420
store_kv(pool, KV_VAPID_PUBLIC_KEY, &public_key).await?;

0 commit comments

Comments
 (0)