Request with X509 Certificate

可紊 提交于 2019-12-04 06:50:37

PEM_read_bio expects certificate in PEM format, while you have certificate in "raw" DER format. Obviously you need to convert your certificate to PEM format.

BTW .cer files in DER format don't contain private key and can't be used for signing anything.

You need to re-check what you actually have in your .cer file and in what format.

A follow up on this:

Only .cer file probably means that the private key is in the certificate (well that's the case with the Azure certs), you will have to transform in a PEM file (that starts with ----BEGIN RSA PRIVATE KEY----) and then do a request with:

var key = fs.readFileSync("./key.pem");
var options = {
    cert: key,
    key: key
}

Getting the private key from the file can be a bit tricky, but this worked on Azure certificates, so it might help any of you:

openssl pkcs12 -in ' + file + ' -nodes -passin pass:

(note the empty pass argument)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!