Ich versuche, Websocket zu verwenden, um eine Verbindung zu einem TLS-Server mithilfe von react-native herzustellen. Unten ist mein Code (auf Windows + Android läuft):React-native websocket TLS-Verbindung
var ws = new WebSocket('wss://hub.fingi-staging.com:20020',{
rejectUnauthorized: false
});
ws.onopen =() => {
// connection opened
ws.send('something'); // send a message
};
ws.onmessage = (e) => {
// a message was received
console.log('message : ' + e.data);
};
ws.onerror = (e) => {
// an error occurred
console.log('error:'+e.message);
};
ws.onclose = (e) => {
// connection closed
console.log('close:'+e.code, e.reason);
};
Es ist jedoch nicht mit: error:java.security.cert.CertPathValidatorException: Trust anchor for certification path not found
. Dies liegt daran, dass der Server ein selbstsigniertes Zertifikat verwendet.
Gibt es eine Möglichkeit, das zu beheben?