简体   繁体   English

使用StartSSL证书在Mac OSX上的Node.js上启动HTTPS时出错

[英]Error when starting HTTPS on Node.js on Mac OSX using StartSSL cert

I am splitting hairs trying to get HTTPS server running using StartSSL cert. 我试图让使用StartSSL证书运行HTTPS服务器。 I got all the necessary files from them and I use them by passing them in the createServer arguments: 我从他们那里得到了所有必要的文件,我通过在createServer参数中传递它们来使用它们:

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. 我想也许我应该将证书转换为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. 更新:这只发生在OSX上。 I tried running the same thing on a Ubuntu server and it works. 我尝试在Ubuntu服务器上运行相同的东西,它的工作原理。

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. 但是我可以确认在我的机器上(macbook osx 10.7.3)节点https现在使用自签名证书运行时没有错误。

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 - eg FS.readFileSync(__dirname + 'ssl.crt'). 首先,尝试使用绝对路径 - 例如FS.readFileSync(__ dirname +'ssl.crt')。

also open your cert and key files and confirm that they contain data in the form: '-----BEGIN '... etc. 还打开您的证书和密钥文件,并确认它们包含以下格式的数据:'----- BEGIN'......等。

also notice that while your files are .cert and .key files, the documentation refers to certificate and key files with the .pem extension. 另请注意,虽然您的文件是.cert和.key文件,但文档引用了扩展名为.pem的证书和密钥文件。

http://nodejs.org/api/https.html 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: 这是一个将.csr文件转换为.pem文件的命令:

openssl x509 -req -in certrequest.csr -signkey privatekey.pem -out certificate.pem 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/ 摘自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. 我想你跟着这篇文章https://tootallnate.net/setting-up-free-ssl-on-your-node-server一样,我遇到了同样的问题。 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. 但是在多次检查我从StartCom检索到的所有文件后,我发现我不小心将认证和私钥保存为UTF8,而不是ANSI。 After changing the encoding of the files to ANSI, node.js started working like a charm :) 在将文件的编码更改为ANSI之后,node.js开始像魅力一样工作:)

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

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