当前位置: 首页 > news >正文

电子工厂网站建设用ssh做网站

电子工厂网站建设,用ssh做网站,济宁十大外贸公司,我想做个网站怎么做的应用通过TLS Socket进行加密数据传输 开发步骤 客户端TLS Socket流程: 1.import需要的socket模块。 2.绑定服务器IP和端口号。 3.双向认证上传客户端CA证书及数字证书;单向认证只上传CA证书,无需上传客户端证书。 4.创建一个TLSSocket连接…

应用通过TLS Socket进行加密数据传输
开发步骤
客户端TLS Socket流程:
1.import需要的socket模块。

2.绑定服务器IP和端口号。

3.双向认证上传客户端CA证书及数字证书;单向认证只上传CA证书,无需上传客户端证书。

4.创建一个TLSSocket连接,返回一个TLSSocket对象。

5.(可选)订阅TLSSocket相关的订阅事件。
6.发送数据。

7.TLSSocket连接使用完毕后,主动关闭。

// 创建一个(双向认证)TLS Socket连接,返回一个TLS Socket对象。
import socket from '@ohos.net.socket';let tlsTwoWay: socket.TLSSocket = socket.constructTLSSocketInstance();// 设置通信过程中使用参数
let options = {ALPNProtocols: ["spdy/1", "http/1.1"],// 连接到指定的IP地址和端口。address: {address: "192.168.xx.xxx",port: xxxx, // 端口family: 1,},// 设置用于通信过程中完成校验的参数。secureOptions: {key: "xxxx",                            // 密钥cert: "xxxx",                           // 数字证书ca: ["xxxx"],                           // CA证书passwd: "xxxx",                         // 生成密钥时的密码protocols: [socket.Protocol.TLSv12],    // 通信协议useRemoteCipherPrefer: true,            // 是否优先使用对端密码套件signatureAlgorithms: "rsa_pss_rsae_sha256:ECDSA+SHA256",    // 签名算法cipherSuite: "AES256-SHA256",           // 密码套件},
};// 绑定本地IP地址和端口。
tlsTwoWay.bind({ address: '192.168.xxx.xxx', port: xxxx, family: 1 }, err => {if (err) {console.log('bind fail');return;}console.log('bind success');// 订阅TLS Socket相关的订阅事件tlsTwoWay.on('message', value => {console.log("on message")let buffer = value.messagelet dataView = new DataView(buffer)let str = ""for (let i = 0; i < dataView.byteLength; ++i) {str += String.fromCharCode(dataView.getUint8(i))}console.log("on connect received:" + str)});tlsTwoWay.on('connect', () => {console.log("on connect")});tlsTwoWay.on('close', () => {console.log("on close")});// 建立连接tlsTwoWay.connect(options).then(() => {console.log('connect success');// 发送数据let sendBuf = 'client send to server...';tlsTwoWay.send(sendBuf).then(() => {console.log('client send ok');}).catch((err: Object) => {console.error('client send err: ' + JSON.stringify(err));})}).catch((err: Object) => {console.log('connect failed ' + JSON.stringify(err));});// 连接使用完毕后,主动关闭。取消相关事件的订阅。tlsTwoWay.close().then(() => {console.log('close success');}).catch((err: Object) => {console.log('close failed ' + JSON.stringify(err));});tlsTwoWay.off('message');tlsTwoWay.off('connect');tlsTwoWay.off('close');
});
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.

复制

本文参考引用HarmonyOS官方开发文档,基于API9。

http://www.yayakq.cn/news/322803/

相关文章:

  • 老网站改版做别的天津手机网站建设制作
  • 个人网站策划书模板网站后台管理系统制作教程
  • 昆山开发区网站制作百度官网认证多少钱一年
  • 冷门行业做网站的优势海外营销网站建设
  • 学校网站建设开发商wordpress 单页面模板
  • 商务网站要怎么设计cn域名网站
  • 怎么做网站标题优化免费空间搭建免费小说网站
  • 门户网站登录入口网页设计代码水平对齐属性align
  • 四川网站建设价格大连网站空间
  • 黄骅贴吧金宝海南搜索引擎优化
  • 沃尔玛官方网站查余额网站建设预算项目
  • 网站建设与维护 实训WordPress站点地图代码
  • 智能响应式网站建设河北智能网站建设多少钱
  • 网站内容管理系统源码网站建设丷金手指专业十五
  • 手机在线网站地区网站建设
  • 大学生商品网站建设自媒体网站建设论文
  • 乐从网站制作wordpress 文章路径
  • 网站婚礼服务态网站建设论文错乱变装wordpress
  • 滨州医学院做计算机作业的网站深圳app开发公司前十名
  • 下载正品官方网站在百度上做网站推广效果怎么样
  • 量力商务大厦网站建设logo高清图片
  • 免费发布工程信息网站怎样设计公司logo
  • 卖东西怎么做网站国外wordpress主机
  • 网站后台图片上传失败广州通和通信建设有限公司网站
  • 怀化公司网站建设黑镜wordpress主题
  • 关于加强内网网站建设的通知音乐网站模板免费源码
  • 公司建设网站费用属于什么费用网络设计课程中对网页设计的报告
  • 网站内容百度不收录合肥刚刚通报阳性
  • 网站挂服务器后图片不显示Wordpress 标签无用
  • 软件开发公司网站电脑中怎样安装wordpress