express httpsサービスの使用
1455 ワード
1.証明書の生成
2.注入証明書
ネット上にはまだまだ実力がある
https://blog.csdn.net/f826760951/article/details/67639309
https://blog.csdn.net/u012353243/article/details/53409159
openssl genrsa 1024 > ./private.pem # key
openssl req -new -key ./private.pem -out csr.pem # CSR
openssl x509 -req -days 365 -in csr.pem -signkey ./private.pem -out ./file.crt # CSR
]
2.注入証明書
const http = require('http');
const server = http.createServer(app);
//
const port = normalizePort(process.env.PORT || '443');
const path = require('path');
const https = require('https');
const fs = require('fs');
const options = {
key: fs.readFileSync(path.join(__dirname, './private.pem')),
cert: fs.readFileSync(path.join(__dirname, './file.crt'))
}
//
var httpsServer = https.createServer(options, app);
var httpServer = http.createServer(app);
// //https 3000
httpsServer.listen(3001, 'localhost', () => {
console.log('Example app listening on port 3000!')
});
//http 3001
httpServer.listen(3000, 'localhost', () => {
console.log('Example app listening on port 3000!')
});
ネット上にはまだまだ実力がある
https://blog.csdn.net/f826760951/article/details/67639309
https://blog.csdn.net/u012353243/article/details/53409159