【问题标题】:error reading X.509 key or certificate file: Error in parsing when sending certificate in Curl Request读取 X.509 密钥或证书文件时出错:在 Curl 请求中发送证书时解析出错
【发布时间】:2018-05-17 11:47:49
【问题描述】:

我使用 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 请求中发送证书时解析出错

我该如何克服这个问题?

【问题讨论】:

    标签: ssl curl certificate x509


    【解决方案1】:

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

    从以下请求生成的证书正常工作。

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

    【讨论】:

      猜你喜欢
      • 2017-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-23
      • 1970-01-01
      相关资源
      最近更新 更多