zoukankan      html  css  js  c++  java
  • curl-users unable to set private key file ?

    转自:https://curl.haxx.se/mail/archive-2005-09/0138.html

    Greetings CURL users!

    I just subscribed to the list and would like to share a problem and it's
    solution, after a couple of hours working around it... I was going to write
    to the list for help ;)

    I was having problems using Curl to connect to a https server using a client
    certificate. I believe i was doing everything by the book, but somehow Curl
    kept complaining about the private key file.

    1) I had a PKCS#12 file which contained the CA and Client certificates and
    the private key: "MULTICERT.p12"

    2) I convert it to PEM format with:
    openssl pkcs12 -in MULTICERT.p12 -out cert.pem
    Enter Import Password:
    MAC verified OK
    Enter PEM pass phrase:
    Verifying - Enter PEM pass phrase:

    and the file cert.pem was created with all the certificates and the private
    key (i used "xxxxxx" for the PEM pass phrase).

    3) However when i used Curl to connect to the https server

    curl -d "var1=value1&var2=value2&..." -G -v --cert cert.pem:xxxxxx
    https://www.somesite.com/page
    * About to connect() to www.somesite.com port 443
    * Trying 123.123.123.123... * connected
    * Connected to www.somesite.com (123.123.123.123) port 443
    * unable to set private key file: 'cert.pem' type PEM

    * Closing connection #0
    curl: (58) unable to set private key file: 'cert.pem' type PEM

    4) So then i tried to put the CA certificate, Client Certificate and Private
    Key in separate files:
    openssl pkcs12 -in MULTICERT.p12 -out ca.pem -cacerts -nokeys
    openssl pkcs12 -in MULTICERT.p12 -out client.pem -clcerts -nokeys
    openssl pkcs12 -in MULTICERT.p12 -out key.pem -nocerts

    and then i tried Curl again:

    curl -d "var1=value1&var2=value2&..." -G -v --key key.pem --cacert
    ca.pem --cert client.pem:xxxxxx https://www.somesite.com/page

    and it worked!!! :)

    Still don't know why the first method - having everything in one cert file -
    didn't work...!?
    Maybe the proivate key was'nt on the right order...

    Well, anyway, hope this helps anyone

    Cheers!

  • 相关阅读:
    ASP.NET缓存全解析(系列)
    updateprogress用法技巧
    text与img对齐
    9款Firefox插件提高设计开发效率
    ASP.NET页面实时进行GZIP压缩优化
    如何收缩和删除SQL日志文件
    闲扯加班
    与大家分享一点游戏管理晋升的心得(完整版)
    FDS (Flex Data Services)
    和我老婆去旅游
  • 原文地址:https://www.cnblogs.com/z1500592/p/10338180.html
Copyright © 2011-2022 走看看