refactor: Change config private key type to K256Secret #30

Manually merged
awiteb merged 4 commits from awiteb/config-private-key-type into master 2024-07-24 00:20:19 +02:00 AGit
Showing only changes of commit 0b56faebae - Show all commits

View file

@ -23,7 +23,7 @@ use chrono::Utc;
use errors::{WsError, WsResult}; use errors::{WsError, WsResult};
use futures::{channel::mpsc, FutureExt, StreamExt, TryStreamExt}; use futures::{channel::mpsc, FutureExt, StreamExt, TryStreamExt};
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use oxidetalis_core::{cipher::K256Secret, types::PublicKey}; use oxidetalis_core::types::PublicKey;
use oxidetalis_entities::prelude::*; use oxidetalis_entities::prelude::*;
use salvo::{ use salvo::{
handler, handler,
@ -102,9 +102,7 @@ pub async fn user_connected(
let db_conn = depot.db_conn(); let db_conn = depot.db_conn();
let public_key = let public_key =
utils::extract_public_key(req).expect("The public key was checked in the middleware"); utils::extract_public_key(req).expect("The public key was checked in the middleware");
// FIXME: The config should hold `K256Secret` not `PrivateKey` let shared_secret = depot.config().server.private_key.shared_secret(&public_key);
let shared_secret =
K256Secret::from_privkey(&depot.config().server.private_key).shared_secret(&public_key);
WebSocketUpgrade::new() WebSocketUpgrade::new()
.upgrade(req, res, move |ws| { .upgrade(req, res, move |ws| {