curl: (58) Unable to load client key -8178

前端 未结 2 508
情话喂你
情话喂你 2021-02-01 16:53

I am facing an SSL issue with the curlcommand. I want to reach an URL using my SSL client certificate and private key.

This is my command:

$         


        
相关标签:
2条回答
  • 2021-02-01 17:32

    I've gone through the same problem, and found a solution finally, maybe it can help you.

    The failure was due to the private key in PKCS#8 format:

    • a PKCS#8 private key starts with -----BEGIN ENCRYPTED PRIVATE KEY----- header
      or
      -----BEGIN PRIVATE KEY----- header

      With this key curl + openssl will works, but curl + nss + libnsspem.so wouldn't.

    • with a RSA private key which starts with
      -----BEGIN RSA PRIVATE KEY----- header

      both curl + openssl and curl + nss + libnsspem.so will work.

    So use this command

    openssl pkcs8 -in path/to/your/pkcs8/key -out path/to/rsa/key
    

    to convert the PKCS#8 key to traditional RSA key.

    0 讨论(0)
  • 2021-02-01 17:49

    If your certificate has a passphrase you should add it after the certificate name:

    curl -k -v "https://myurl.com/" --cert ./certificate.pem:passphrase --key ./private.key
    
    0 讨论(0)
提交回复
热议问题