博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
本地ssl证书生成_如何生成本地SSL证书
阅读量:2506 次
发布时间:2019-05-11

本文共 1242 字,大约阅读时间需要 4 分钟。

本地ssl证书生成

Note: I ran these commands on macOS. Linux should work in the same way. I don’t guarantee for Windows.

注意:我在macOS上运行了这些命令。 Linux应该以相同的方式工作。 我不保证使用Windows。

In the project root folder, run:

在项目根文件夹中,运行:

openssl req -x509 -newkey rsa:2048 -keyout keytmp.pem -out cert.pem -days 365

Now run:

现在运行:

openssl rsa -in keytmp.pem -out key.pem

You should now have the files cert.pem and key.pem in the folder.

现在,您应该在文件夹中包含文件cert.pemkey.pem

With Express/Node.js, you can load the certificate and key using this code:

使用Express / Node.js,您可以使用以下代码加载证书和密钥:

const fs = require('fs')const https = require('https')const app = express()app.get('/', (req, res) => {  res.send('Hello HTTPS!')})https.createServer({  key: fs.readFileSync('key.pem'),  cert: fs.readFileSync('cert.pem')}, app).listen(3000, () => {  console.log('Listening...')})

If you’re using create-react-app, change the start script in the package.json file to:

如果您使用的是create-react-app ,请将package.json文件中的start脚本更改为:

"start": "export HTTPS=true&&SSL_CRT_FILE=cert.pem&&SSL_KEY_FILE=key.pem react-scripts start",

Look at your framework/library documentation on the instructions on how to pass the certificate and key to the app.

请参阅您的框架/库文档,以获取有关如何将证书和密钥传递给应用程序的说明。

翻译自:

本地ssl证书生成

转载地址:http://qamgb.baihongyu.com/

你可能感兴趣的文章
腾讯的张小龙是一个怎样的人?
查看>>
jxl写入excel实现数据导出功能
查看>>
linux文件目录类命令|--cp指令
查看>>
.net MVC 404错误解决方法
查看>>
linux系统目录结构
查看>>
git
查看>>
btn按钮之间事件相互调用
查看>>
Entity Framework 4.3.1 级联删除
查看>>
codevs 1163:访问艺术馆
查看>>
冲刺Noip2017模拟赛3 解题报告——五十岚芒果酱
查看>>
并查集
查看>>
sessionStorage
查看>>
代码示例_进程
查看>>
Java中关键词之this,super的使用
查看>>
人工智能暑期课程实践项目——智能家居控制(一)
查看>>
前端数据可视化插件(二)图谱
查看>>
kafka web端管理工具 kafka-manager【转发】
查看>>
获取控制台窗口句柄GetConsoleWindow
查看>>
Linux下Qt+CUDA调试并运行
查看>>
3.1.1;例3-1
查看>>