node.js - 如何在节点中使用 ssl 制作服务器?
问题描述
尝试使用 SSL 在节点上创建服务器时出错。我所做的如下:
首先,我生成了密钥对和这样的 CA:
1 - 我生成了私钥:
openssl genrsa -out mykey.pem 1024
2 - 我生成了公钥:
openssl rsa -in mykey.pem -pubout > publickey.pub
3 - 我生成了 CA:
openssl req -new -x509 -key mykey.pem -out certificate.cer -days 1825
从那里我在节点中创建了选项:
options = {
key: fs.readFileSync(pathKey),
cert: fs.readFileSync(pathSSLCertificate)
};
其中pathKey和pathSSLCertificate分别是私钥和公钥路径。
然后使用restify:
server = restify.createServer(options);
但是它给出了以下错误:
library: 'PEM routines',
function: 'get_name',
reason: 'no start line',
code: 'ERR_OSSL_PEM_NO_START_LINE'
使用https://www.sslchecker.com/certdecoder进行测试
显示消息:
格式不正确或 SSL 文件已损坏
解决方案
推荐阅读
- eclipse - Painless 和迁移的测试功能
- android - Kotlin + SimpleXMLElement + Map 子列表元素
- flutter -
- java - 如何有效地找到单个像素值随时间变化的标准偏差?(来自视频源)
- php - 如何使用 PHP curl 发布 $_FILES?
- php - 尝试使用formdata上传图像并在reactnative中获取api但是当尝试在php文件中打印formdata时没有图像数据是为什么?
- sanity - 为什么在 Sanity.IO 中没有正确准备渲染
- arrays - 如何将数组传入和传出函数?
- java - 如何画一个光滑的椭圆?
- r - 使用 ggplot2 有条件地为条形图分配 geom_text 位置