皇冠篮球比分网

您的位置:皇冠篮球比分网 >新闻资讯 > 正文

如何将浏览器与代理之间的流量传输升级为HTTPS?

来源:互联网 作者:admin 时间:2019-10-22 16:15:46

  HTTPDAILIKEYIFENWEIPUTONGDAILIYIJISUIDAODAILI,JINTIANWOMENYAOJIESHAODESHIRUHEJIANGLIULANQIYUDAILIZHIJIANDELIULIANGCHUANSHUSHENGJIWEI HTTPS?XIAMIANMASHANGJINRUDAOJIAOCHENGBUFEN。


将流量传输升级为HTTPS


  WOMENZHIDAO TLS YOUSANDAGONGNENG:NEIRONGJIAMI、SHENFENRENZHENGHESHUJUWANZHENGXING。QIZHONGNEIRONGJIAMIYILAIYUMIYAOXIESHANGJIZHI;SHUJUWANZHENGXINGYILAIYU MAC(Message authentication code)XIAOYANJIZHI;ERSHENFENRENZHENGZEYILAIYUZHENGSHURENZHENGJIZHI。YIBANCAOZUOXITONGHUOLIULANQIHUIWEIHUYIGESHOUXINRENGENZHENGSHULIEBIAO,BAOHANZAILIEBIAOZHIZHONGDEZHENGSHU,HUOZHEYOULIEBIAOZHONGDEZHENGSHUQIANFADEZHENGSHUDOUHUIBEIKEHUDUANXINREN。


皇冠篮球比分网  TIGONG HTTPS FUWUDEZHENGSHUKEYIZIJISHENGCHENG,RANHOUSHOUDONGJIARUDAOXITONGGENZHENGSHULIEBIAOZHONG。DANSHIDUIWAITIGONGFUWUDE HTTPS WANGZHAN,BUKENENGYAOQIUMEIGEYONGHUDOUSHOUDONGDAORUNIDEZHENGSHU,SUOYIGENGCHANGJIANDEZUOFASHIXIANG CA(Certificate Authority,ZHENGSHUBANFAJIGOU)SHENQING。GENJUZHENGSHUDEBUTONGJIBIE,CA HUIJINXINGBUTONGJIBIEDEYANZHENG,YANZHENGTONGGUOHOU CA HUIYONGTAMENDEZHENGSHUQIANFAWANGZHANZHENGSHU,ZHEIGEGUOCHENGTONGCHANGSHISHOUFEIDE(YOUMIANFEIDEZHENGSHU,ZUIJINMIANFEIDE Let's Encrypt YEHENHUO,ZHEILIBUDUOJIESHAO)。YOUYU CA SHIYONGDEZHENGSHUDOUSHIYOUGUANGFANNEIZHIZAIGEXITONGZHONGDEGENZHENGSHUQIANFA,SUOYICONG CA HUODEDEWANGZHANZHENGSHUHUIBEIJUEDABUFENKEHUDUANXINREN。


  TONGGUO CA SHENQINGZHENGSHUHENJIANDAN,BENWENWEILEFANGBIANYANSHI,CAIYONGZIJIQIANFAZHENGSHUDETOULANBANFA。XIANZAIGUANGFANSHIYONGDEZHENGSHUSHI x509.v3 GESHI,SHIYONGYIXIAMINGLINGKEYICHUANGJIAN:


  openssl genrsa -out private.pem 2048

  openssl req -new -x509 -key private.pem -out public.crt -days 99999


  DIERXINGMINGLINGYUNXINGHOU,XUYAOTIANXIEYIXIEZHENGSHUXINXI。XUYAOZHUYIDESHI Common Name YIDINGYAOTIANXIEHOUXUTIGONG HTTPS FUWUDEYUMINGHUO IP。LIRUNIDASUANZAIBENDICESHI,Common Name KEYITIANXIE 127.0.0.1。ZHENGSHUCHUANGJIANHAOZHIHOU,ZAIJIANG public.crt TIANJIADAOXITONGSHOUXINRENGENZHENGSHULIEBIAOZHONG。WEILEQUEBAOTIANJIACHENGGONG,KEYIYONGLIULANQIYANZHENGYIXIA。


  JIEZHE,KEYIGAIZAOZHIQIANDE Node.js DAIMALE,XUYAOGAIDONGDEDIFANGBUDUO:


  JSvar http = require('http');

  var https = require('https');

  var fs = require('fs');

  var net = require('net');

  var url = require('url');

  function request(cReq, cRes) {

  var u = url.parse(cReq.url);

皇冠篮球比分网  var options = {

皇冠篮球比分网  hostname : u.hostname,

皇冠篮球比分网  port : u.port || 80,

  path : u.path,

  method : cReq.method,

皇冠篮球比分网  headers : cReq.headers

  };

  var pReq = http.request(options, function(pRes) {

皇冠篮球比分网  cRes.writeHead(pRes.statusCode, pRes.headers);

  pRes.pipe(cRes);

  }).on('error', function(e) {

  cRes.end();

  });

  cReq.pipe(pReq);

  }

皇冠篮球比分网  function connect(cReq, cSock) {

  var u = url.parse('http://' + cReq.url);

  var pSock = net.connect(u.port, u.hostname, function() {

  cSock.write('HTTP/1.1 200 Connection Established\r\n\r\n');

  pSock.pipe(cSock);

  }).on('error', function(e) {

皇冠篮球比分网  cSock.end();

  });

皇冠篮球比分网  cSock.pipe(pSock);

  }

  var options = {

  key: fs.readFileSync('./private.pem'),

  cert: fs.readFileSync('./public.crt')

  };

  https.createServer(options)

  .on('request', request)

  .on('connect', connect)

皇冠篮球比分网  .listen(8888, '0.0.0.0');


皇冠篮球比分网  KEYIKANDAO,CHULEJIANG http.createServer HUANCHENG https.createServer,ZENGJIAZHENGSHUXIANGGUANPEIZHIZHIWAI,ZHEIDUANDAIMAMEIYOURENHEGAIBIAN。ZHEIYESHIYINRU TLS CENGDEMIAOCHU,YINGYONGCENGBUXUYAORENHEGAIDONG,JIUNENGHUODEZHUDUOANQUANTEXING。


  YUNXINGFUWUHOU,ZHIXUYAOJIANGLIULANQIDEDAILISHEZHIWEI HTTPS 127.0.0.1:8888 JIKE,GONGNENGZHAOJIU。ZHEIYANGGAIZAO,ZHISHIJIANGLIULANQIDAODAILIZHIJIANDELIULIANGSHENGJIWEILE HTTPS,DAILIZISHENLUOJI、YUFUWUDUANDETONGXUNFANGSHI,DOUMEIYOURENHEBIANHUA。


  ZUIHOU,HAISHIXIEDUAN Node.js DAIMAYANZHENGXIAZHEIGE HTTPS DAILIFUWU:


  JSvar https = require('https');

皇冠篮球比分网  var options = {

  hostname : '127.0.0.1',

皇冠篮球比分网  port : 8888,

  path : 'imququ.com:80',

  method : 'CONNECT'

  };

  //JINYONGZHENGSHUYANZHENG,BURANZIQIANMINGDEZHENGSHUWUFAJIANLI TLS LIANJIE

  process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";

皇冠篮球比分网  var req = https.request(options);

皇冠篮球比分网  req.on('connect', function(res, socket) {

皇冠篮球比分网  socket.write('GET / HTTP/1.1\r\n' +

  'Host: imququ.com\r\n' +

皇冠篮球比分网  'Connection: Close\r\n' +

皇冠篮球比分网  '\r\n');

  socket.on('data', function(chunk) {

  console.log(chunk.toString());

  });

  socket.on('end', function() {

  console.log('socket end.');

  });

  });

  req.end();


皇冠篮球比分网  YISHANGJIUSHICAOZUODEZHONGDIANBUZHOUYIJIZHUYAODAIMA,DAJIARUGUOYOUYIWEN,HUANYINGLIANXIETDAILIDEKEFU。


皇冠篮球比分网相关的文章内容简介