我如何在React Native应用程序中连接到TLS套接字连接

时间:2019-03-14 19:18:32

标签: react-native ssl tcp websocket tls1.2

我正在尝试使用TLS 1.2协议连接到SSL套接字。这是我的代码:

const client = new WebSocket('wss://<domain-name>');

client.onopen = () => {
    console.log('socket openend');      
};

this.client.onmessage = messageFunction;
this.client.onerror = errorFunction;
this.client.onclose = closeFunction;

并且连接立即关闭。我认为可能是由于服务器不接受我的证书,所以我使用react-native-cert-pinner来固定所有相关的SHA256引脚,但还是没有运气。

作为参考,使用tls模块可以使用以下node.js代码:

const tls = require('tls');

const client = tls.connect({ host: '<domain-name>', port: 443 }, () => console.log('connected');

对于该问题的任何建议或见解,将不胜感激。

0 个答案:

没有答案