Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ssl 读取X.509密钥或证书文件时出错:在Curl请求中发送证书时解析出错_Ssl_Curl_Certificate_X509 - Fatal编程技术网

Ssl 读取X.509密钥或证书文件时出错:在Curl请求中发送证书时解析出错

Ssl 读取X.509密钥或证书文件时出错:在Curl请求中发送证书时解析出错,ssl,curl,certificate,x509,Ssl,Curl,Certificate,X509,我使用openssl使用以下命令生成自签名证书 openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365ls 我用curl命令发送这个cert.pem curl --header 'Accept: application/json' --header 'Authorization: Bearer 043473b9-5cf4-3dcc-b7a6-32813f6e4df2' 'https://localho

我使用openssl使用以下命令生成自签名证书

openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365ls
我用curl命令发送这个cert.pem

curl --header 'Accept: application/json' --header 'Authorization: Bearer 043473b9-5cf4-3dcc-b7a6-32813f6e4df2' 'https://localhost:8243/pizzashack/1.0.0/menu' --cert cert.pem --key key.pem -k -v
但此操作失败,错误为:读取X.509密钥或证书文件时出错:在Curl请求中发送证书时解析时出错


如何克服这个问题?

这里有一个解决方案。当curl无法解密默认加密的my key.pem文件时,会发生这种情况。我们可以在生成证书时使用-nodes指令来避免加密密钥

根据以下请求生成的证书工作正常

openssl req -newkey rsa:2048 -x509 -keyout pii_key.pem -out piisp.pem -days 3650 -nodes