我正在尝试设置用于本地开发的https服务器。我使用的是Windows 10计算机。我已经使用openssl生成了一个自签名证书。我使用了以下命令。
openssl genrsa -out key.pem
openssl req -new -key key.pem -out csr.pem
openssl x509 -req -days 9999 -in csr.pem -signkey key.pem -out cert.pem
rm csr.pem
这是演示服务器代码(NodeJS),它输出"hello world“。
const https = require('https');
const fs = require('fs');
const options = {
key: fs.readFileSync('key.pem'),
cert: fs.readFileSync('cert.pem')
};
https.createServer(options, function (req, res) {
res.writeHead(200);
res.end("hello world\n");
}).listen(8000);
我已经使用curl命令从命令提示符访问了URL
curl https://localhost:8000
我得到的错误是
curl: (35) schannel: SNI or certificate check failed: SEC_E_WRONG_PRINCIPAL (0x80090322) - The target principal name is incorrect.
我已经使用"Microsoft管理控制台(mmc)“在”受信任的根证书颁发机构“存储中添加了自签名证书。这是我的Certificate image。
我不知道我错在哪里。请帮我解决这个问题。
发布于 2021-04-19 23:21:53
您还可以将-k开关与CURL一起使用,以忽略SSL证书错误。显然,对于您希望确保证书良好的环境,不建议这样做。
https://stackoverflow.com/questions/61940008
复制相似问题