I would like to spawn a ws server easily with wss support without generate myself the certificate.
does it possible?
My code:
use futures::StreamExt;
use futures::FutureExt;
use warp::Filter;
#[tokio::main]
async fn main() {
let echo = warp::path("echo")
.and(warp::ws())
.map(|ws: warp::ws::Ws| {
ws.on_upgrade(|websocket| {
let (tx, rx) = websocket.split();
rx.forward(tx).map(|result| {
if let Err(e) = result {
eprintln!("websocket error: {:?}", e);
}
})
})
});
let current_dir = std::env::current_dir().expect("failed to read current directory");
let routes = warp::get().and(echo.or(warp::fs::dir(current_dir)));
warp::serve(routes)
.tls()
// .cert_path("cert.pem") // <--- I want to avoide this line
// .key_path("key.rsa") // <--- I want to avoide this line
.run(([0, 0, 0, 0], 9231)).await;
}
I would like to spawn a
ws
server easily withwss
support without generate myself the certificate. does it possible?My code: