I have a NodeJs Application running with express. I have been trying to integrate an SSL certificate but I keep having the same error: Error: error:0906D06C:PEM routines:PEM_read_bio:no start line.
I have tried some solutions I found on stackOverflow like
if (process.env.SSL_PRIVATE_KEY && process.env.SSL_CERTIFICATE) {
server = require('https');
server.createServer({
key: fs.readFileSync(path.resolve('ssl/key.pem'), 'utf8'),
cert: fs.readFileSync(path.resolve('ssl/server.crt'), 'utf8'),
ca: fs.readFileSync(path.resolve('ssl/bundle.crt'), 'utf8'),
requestCert: false,
rejectUnauthorized: false
}, app).listen(app.get('port'), function () {
console.log('Express server listening on https://localhost:' + app.get('port'));
});
} else {
server = require('http');
server.createServer(app).listen(app.get('port'), function () {
console.log('Express server listening on http://localhost:' + app.get('port'));
});
But none seem to work. My main problem is that I donwloaded my certificate file from GoDaddy but I only get two.cert files. I have read in some websites how to obtain the.pem files but I keep getting the same error.
As you can see I am new at using https protocol in NodeJs.
Could you help me solve this problem?
Best regards
Already solved. Actually the files that GoDaddy gave me was in the wrong format, therefore I called support, they did not know how to solve it and I had to refund the money, therefore, add the HTTPS protocol with Let's Encrypt.
From godaddy, you will have 5 file: 1- Key which is in Text Format 2- CSR Text format 3- pem file 4- crt file 5- bundle crt file
What you have to do is rename the key to a.pem file then open then change the format to utf8. On Mac
The code with fs.ReadfileSync will work one: First is the Key file, second is the PEM file downloaded, and third is the bundle
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.