Hi, I'm working on web sockets for which I used the "tungstenite" crate. While working on windows, the application was working fine, but when I tried the same in Linux machine I was getting "certificate verify failed" error.
Code:
use tauri::Manager;
use tungstenite::{connect, Message};
use url::Url;
use std::sync::{Mutex};
fn main() {
let (socket, _response) = connect(Url::parse("wss://127.0.0.1:8080/ws").unwrap()).expect("Failed to connect");
println!("WebSocket Connection Established !! \n");
tauri::Builder::default()
.setup(move |app|{
let app_ = app.handle();
let stream = Mutex::new(socket);
app.listen_global("request", move |_handler| {
let mut data = stream.lock().unwrap();
data.write_message(Message::Text(r#"{
"type": "config"
}"#.to_string()+"\n")).unwrap();
let msg = data.read_message().expect("Error reading message");
let message = msg.to_string();
let parsed: serde_json::Value = serde_json::from_str(&message).expect("Can't parse to JSON");
app_.emit_all("socket-response", parsed).unwrap();
});
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
Error:
thread 'main' panicked at 'Failed to connect: Tls(Native(Ssl(Error { code: ErrorCode(1), cause: Some(Ssl(ErrorStack([Error { code: 337047686, library: "SSL routines", function: "tls_process_server_certificate", reason: "certificate verify failed", file: "../ssl/statem/statem_clnt.c", line: 1913 }]))) }, X509VerifyResult { code: 20, error: "unable to get local issuer certificate" })))', src/main.rs:8:87
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Can someone let me know how to solve this error?