91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

用Node.js實現基于https的Restful風格webservice

發布時間:2020-07-17 16:18:47 來源:網絡 閱讀:1409 作者:h2appy 欄目:web開發

1. 創建證書文件

bash-3.2$ 

bash-3.2$ mkdir ssl

bash-3.2$ cd ssl

bash-3.2$ openssl genrsa -out key.pem 1024

Generating RSA private key, 1024 bit long modulus

....................................++++++

..........++++++

e is 65537 (0x10001)

bash-3.2$ openssl req -new -key key.pem -out certrequest.csr

You are about to be asked to enter information that will be incorporated

into your certificate request.

What you are about to enter is what is called a Distinguished Name or a DN.

There are quite a few fields but you can leave some blank

For some fields there will be a default value,

If you enter '.', the field will be left blank.

-----

Country Name (2 letter code) [AU]:

State or Province Name (full name) [Some-State]:

Locality Name (eg, city) []:

Organization Name (eg, company) [Internet Widgits Pty Ltd]:

Organizational Unit Name (eg, section) []:

Common Name (e.g. server FQDN or YOUR name) []:

Email Address []:


Please enter the following 'extra' attributes

to be sent with your certificate request

A challenge password []:

An optional company name []:

bash-3.2$ 

bash-3.2$ 

bash-3.2$ openssl x509 -req -in certrequest.csr -signkey key.pem -out cert.pem

Signature ok

subject=/C=AU/ST=Some-State/O=Internet Widgits Pty Ltd

Getting Private key

bash-3.2$ 

bash-3.2$ 


2. vim app.js

  1 var express = require('express'), https = require('https'), fs = require('fs');

  2 

  3 var privateKey = fs.readFileSync('./ssl/key.pem').toString();

  4 var certificate = fs.readFileSync('./ssl/cert.pem').toString();

  5 var ca = fs.readFileSync('./ssl/certrequest.csr').toString();

  6 

  7 var options = {

  8       key : privateKey,

  9       cert : certificate,

 10       ca : ca

 11 }

 12 

 13 var app = express();

 14 

 15 //RESTful API

 16 app.get("/testapi", function(req, res){

 17     res.send('test api');

 18 });

 19 

 20 app.get("/", function(req, res){

 21   res.send('');

 22 });

 23 

 24 https.createServer(options, app).listen(443, function() {

 25      console.log('https server started successfully.');

 26 });

 27 

 28 app.listen(80);



3. node app


4.用瀏覽器打開:https://127.0.0.1/testapi


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

屯留县| 罗城| 康保县| 灵丘县| 青岛市| 嘉祥县| 漾濞| 突泉县| 太白县| 九寨沟县| 平山县| 马边| 东乡县| 武清区| 灵宝市| 四子王旗| 托里县| 九江市| 德保县| 府谷县| 鞍山市| 始兴县| 永善县| 高陵县| 隆尧县| 乌拉特前旗| 海安县| 昔阳县| 大名县| 福泉市| 盈江县| 雷州市| 淳安县| 江华| 汉阴县| 耒阳市| 玉环县| 同心县| 英德市| 霸州市| 东源县|