简体   繁体   English

使用Node.js阅读letencrypt证书

[英]Read a letsencrypt cert with Node.js

What might cause this? 是什么原因造成的? I list two certificate files in ~/TC/bin and I see them. 我在〜/ TC / bin中列出了两个证书文件,然后看到了它们。

~/TC/bin$ ls
cert.pem  key.pem

I try to read those files from ~/TC/server.js 我尝试从〜/ TC / server.js读取这些文件

var credentials = {
  key:  fs.readFileSync('bin/key.pem'),
  cert: fs.readFileSync('bin/cert.pem')
};

I get an error message saying they're not found. 我收到一条错误消息,指出找不到它们。 I suspect it may be caused by file permissions though I'm not certain how to appropriately adjust it for something like a secure key asset. 我怀疑它可能是由文件权限引起的,尽管我不确定如何针对诸如安全密钥资产之类的东西适当地对其进行调整。

Error: ENOENT: no such file or directory, open 'bin/key.pem'

when you're not providing slash at the begining you're telling node that he should look for node module (npm). 当您在开始时不提供斜杠时,您告诉节点他应该寻找节点模块(npm)。 Try with ./ as a start. 从./开始尝试。 So './bin/key.pem' 所以'./bin/key.pem'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM