I am splitting hairs trying to get HTTPS server running using StartSSL cert. I got all the necessary files from them and I use them by passing them in the createServer
arguments:
var options =
{
ca: FS.readFileSync('sub.class1.server.ca.pem'),
key: FS.readFileSync('ssl.key'),
cert: FS.readFileSync('ssl.crt')
};
And this is the error I got.
Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
at Object.createCredentials (crypto.js:87:31)
at HTTPSServer.Server (tls.js:914:28)
at HTTPSServer.Server (https.js:33:14)
at HTTPSServer.HTTPSServer (/Users/myUserName/node_modules/connect/lib/https.js:34:16)
at new HTTPSServer (/Users/myUserName/node_modules/express/lib/https.js:38:23)
at Object.createServer (/Users/myUserName/node_modules/express/lib/express.js:43:12)
at Object.<anonymous> (/Users/myUserName/Sites/node.js/https/app.js:12:36)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
I thought maybe I should convert the cert to PEM. But running:
openssl x509 -in ssl.crt -out ssl.der -outform DER
...gives me similar error
unable to load certificate
67304:error:0906D06C:PEM routines:PEM_read_bio:no start line:/SourceCache/OpenSSL098/OpenSSL098-44/src/crypto/pem/pem_lib.c:648:Expecting: TRUSTED CERTIFICATE
Any idea why?
UPDATE: This only happens on OSX. I tried running the same thing on a Ubuntu server and it works.
i was having the same issue. however i can confirm that on my machine (macbook osx 10.7.3) node https now runs without error using a self-signed certificate.
that particular error means that it either cant find the files, or there's nothing in the files (you can confirm this by passing an empty string or using an invalid file path.)
firstly, try using absolute paths - e.g. FS.readFileSync(__dirname + 'ssl.crt').
also open your cert and key files and confirm that they contain data in the form: '-----BEGIN '... etc.
also notice that while your files are .cert and .key files, the documentation refers to certificate and key files with the .pem extension.
http://nodejs.org/api/https.html
from what i understand, there isn't much difference, the contents appear pretty similar to me, but these things can be fiddly.
here is a command to convert a .csr file to a .pem file:
openssl x509 -req -in certrequest.csr -signkey privatekey.pem -out certificate.pem
taken from http://silas.sewell.org/blog/2010/06/03/node-js-https-ssl-server-example/
I think you followed this article https://tootallnate.net/setting-up-free-ssl-on-your-node-server as I did, and I got the same problem as you had. But after checking several times all the files I retrieved from StartCom, I found that I accidentally saved a certification and a private key as UTF8, not ANSI. After changing the encoding of the files to ANSI, node.js started working like a charm :)