【发布时间】:2017-10-27 02:53:15
【问题描述】:
当我尝试读取我的自签名 SSL 证书时,Node 不断给我这个错误
_tls_common.js:67
c.context.setCert(options.cert);
^
Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
at Error (native)
at Object.createSecureContext (_tls_common.js:67:17)
at Object.TLSSocket._init.ssl.onclienthello.ssl.oncertcb.exports.connect (_tls_wrap.js:1017:46)
at Socket.<anonymous> (/usr/blinkchannelserver/bundle/programs/server/npm/node_modules/pg/lib/connection.js:106:23)
at Socket.g (events.js:260:16)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:153:18)
at Socket.Readable.push (_stream_readable.js:111:10)
at TCP.onread (net.js:540:20)
这应该是什么格式?
在我的服务器上,我通过运行创建了一个客户端密钥和 csr
openssl req -new -key ~/.postgresql/postgresql.key -out /tmp/postgresql.csr
我使用我的服务器密钥将 csr 转换为使用我服务器的证书 nd 密钥的证书
openssl x509 -req -in /tmp/postgresql.csr -CA server.cert -CAkey server.key -out /tmp/postgresql.cert -CAcreateserial
当我尝试丢失 postgresql.cert 时,出现上述错误
运行 x509:
openssl x509 -inform PEM -in postgresql.cert
给我一个合理的输出:
-----BEGIN CERTIFICATE-----
MIIDHDCCAgQCCQC8AZE7dSSPZDANBgkqhkiG9w0BAQsFADBRMQswCQYDVQQGEwJH
QjEPMA0GA1UEBwwGTG9uZG9uMR4wHAYDVQQKDBVEb3VnbGFzLVdoaXRlICYgR29z
...
-----END CERTIFICATE-----
【问题讨论】:
-
如果你的CN是
CN=www.example.com,那么很可能是错误的。主机名始终位于 SAN 中。如果它出现在 CN 中,那么它也必须出现在 SAN 中(在这种情况下您必须列出两次)。有关更多规则和原因,请参阅 How do you sign Certificate Signing Request with your Certification Authority 和 How to create a self-signed certificate with openssl? 您还需要将自签名证书放在适当的信任库中。
标签: node.js ssl openssl certificate ssl-certificate