Curl - cannot connect using p12 certificate

后端 未结 1 1803
无人共我
无人共我 2020-12-25 08:34

I\'m trying to collect some data using Curl, connecting to service that some external company provided. They, in addition to address itself, sent me p12

相关标签:
1条回答
  • 2020-12-25 08:55

    Found the solution.

    Easiest way to do this is to extract .pem key and certificate from .p12 file.

    For example (tested on linux):

    openssl pkcs12 -in file.p12 -out file.key.pem -nocerts -nodes
    openssl pkcs12 -in file.p12 -out file.crt.pem -clcerts -nokeys
    

    Will create key/cert pair in current directory.

    Now, to use it:

    curl_setopt($ch, CURLOPT_SSLCERT, 'file.crt.pem');
    curl_setopt($ch, CURLOPT_SSLKEY, 'file.key.pem');
    curl_setopt($ch, CURLOPT_SSLCERTPASSWD, 'pass');
    curl_setopt($ch, CURLOPT_SSLKEYPASSWD, 'pass');
    

    Where pass is the password from .p12 file.

    0 讨论(0)
提交回复
热议问题