react-native - 如何在反应本机应用程序中连接到 TLS 套接字连接
问题描述
我正在尝试使用 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 引脚,但仍然没有运气。
作为参考,以下 node.js 代码可以使用该tls
模块:
const tls = require('tls');
const client = tls.connect({ host: '<domain-name>', port: 443 }, () => console.log('connected');
对此问题的任何建议或见解将不胜感激。
解决方案
推荐阅读
- java - 如何使用实体管理器在春天调用 oracle 存储过程?
- c# - C# 图像 AS3 字节数组
- javascript - 根据内部html向某些项目添加一个类
- android - 光标返回错误的联系人 ID
- c# - 如何在 Windows 10 的系统托盘中显示经典的 BalloonTip 而不是 C# 中的 Toast 通知?
- java - Codility NailingPlanks
- python - 当指定“retain_graph=True”时,PyTorch 的 loss.backward() 是如何工作的?
- c# - Visual Studio 不允许为每个循环选择内部变量 [通过鼠标]?
- latex - 从目录导入包乳胶
- python - 无法将数据帧拆分为固定块(每行)