【问题标题】:Getting error in curl command(curl: (35) error reading X.509 potentially-encrypted key file: Error in parsing.)curl命令出错(curl:(35)读取X.509可能加密的密钥文件时出错:解析时出错。)
【发布时间】:2020-01-27 08:35:54
【问题描述】:

我正在使用以下命令

curl   --insecure  --cert 'cert.p12:password'  -X GET   https://serverUrl   -H 'Content-Type: application/json'


curl   --insecure --cert-type P12 --cert 'cert.p12:password'  -X GET   https://serverUrl   -H 'Content-Type: application/json'

它在 Ubuntu 16.04.4 LTS \n \l (curl 7.47.0 (x86_64-pc-linux-gnu)) (AWS lightsail) 中不起作用并给出以下错误

curl: (35) 读取 X.509 可能加密的密钥文件时出错:解析时出错。

但在 Ubuntu 18.04.3 LTS \n \l (LOCAL SYSTEM)(curl 7.58.0 (x86_64-pc-linux-gnu)) 中工作

【问题讨论】:

    标签: curl certificate ubuntu-16.04 x509certificate ubuntu-18.04


    【解决方案1】:

    由于 Ubuntu 16.04.4 LTS P12 文件不支持,所以我们可以使用以下命令

    PKCS#1 私钥

    openssl pkcs12 -in cert.p12 -nocerts -out privateKey.pem 
    

    证书:

    openssl pkcs12 -in cert.p12 -clcerts -nokeys -out publicCert.pem
    

    我们可以使用下面的命令调用API

    curl -k --cert ./publicCert.pem --cert-type PEM --key ./privateKey.pem --key-type PEM --pass password  -X GET   https://serverUrl   -H 'Content-Type: application/json'
    

    【讨论】:

      猜你喜欢
      • 2017-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-13
      • 1970-01-01
      • 2020-09-15
      相关资源
      最近更新 更多