Open
Description
Issue
Tauri's websocket plugin doesn't come with the security layer enabled
Connecting to any wss
(secured) via the following default example gives an error:
import WebSocket from '@tauri-apps/plugin-websocket';
const ws = await WebSocket.connect('wss://echo.websocket.org');
ws.addListener((msg) => {
console.log('Received Message:', msg);
});
await ws.send('Hello World!');
await ws.disconnect();
GET https://ipc.localhost/plugin%3Awebsocket%7Cconnect net::ERR_CERT_COMMON_NAME_INVALID
:
- thread 'tokio-runtime-worker' panicked at C:\Users\USER\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\rustls-0.23.27\src\crypto\mod.rs:249:14:
no process-level CryptoProvider available -- call CryptoProvider::install_default() before this point
- thread 'tokio-runtime-worker' panicked at C:\Users\USER\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\rustls-0.23.27\src\crypto\mod.rs:249:14:
no process-level CryptoProvider available -- call CryptoProvider::install_default() before this point
Solution
Tauri's websocket plugin users have to install cmake
& cargo add rustls --features ring
& use:
rustls::crypto::ring::default_provider()
.install_default()
.expect("Failed to install rustls crypto provider");