0
const https = require('https');
const fs = require('fs');
const options = {
key: fs.readFileSync('key.pem'),
cert: fs.readFileSync('cert.pem')
};
https.createServer(options,(req,res)=>{
console.log('https server start');
}).listen(8080,'localhost');
尊敬的各位之一, 我試圖讓HTTPS服務器......這個代碼。 但不工作。的node.js本地主機HTTPS服務器無法正常工作什麼
之前,我做到key.pem,cert.pem本地主機服務器
這樣的代碼
openssl genrsa 1024 > key.pem
openssl req -x509 -new -key key.pem > cert.pem
和這件事情在同一文件夾
但不是這樣工作enter image description here
謝謝,並關心。
親愛robertklep。首先感謝你的答案~~~~對我來說,我修復了我的應用程序。真的非常感謝你有美好的一天! –