简体   繁体   中英

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$ ls
cert.pem  key.pem

I try to read those files from ~/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). Try with ./ as a start. So './bin/key.pem'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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