Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using certificate with nuSOAP and cURL 1

Status
Not open for further replies.

miraclemaker

Programmer
Oct 16, 2002
127
GB
Hi I'm using cURL with nuSOAP. I'm requesting a service from a website that requires me to supply a certificate to authenticate myself. I've got two certificates - a .pfx file and a .p7b file. I've installed these on my server but I still can't do any requests. Do I need to specify to cURL to use a certificate when it performs the request?

If so can someone explain how to do this?

Thank a lot.
 
It involves judicious use of the curl_setopt() function.

I've never done client-side certificates with cURL, but I believe that you invoke:

[tt]curl_setopt ($ch, CURLOPT_SSLCERT, $certfile);[/tt]

where $certfile contains the name of the file containing the certificate.

If your certificate file requires a password, invoke:

[tt]curl_setopt ($ch, CURLOPT_SSLCERTPASSWD, $certpassword);[/tt]


One gotcha: cURL can only use PEM and DER-formatted certificate files. cURL defaults to PEM, to specify DER, invoke:

[tt]curl_setopt ($ch, CURLOPT_SSLCERTTYPE, "DER");[/tt]

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thnaks for that. I have two certificates; a .p7b file and a .pfx file. Is there a way to convert these to the required format?

I'm using nuSOAP on windows - where do I need to store the certificates so that they are available to cURL?

Thanks.
 
p7b" is a file extension used by Microsoft -- it follows the PKCS#7 format.

openssl should be able to convert the file:

openssl pkcs7 -inform DER -in <yourfilenamehere>.p7b -print_certs -text -out cert.pem

You can store the certs anywhere on the filesystem. You tell cURL to use the file using the curl_setopt() function I listed above.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thanks for that. I found another resource that advised using openssl. I used the command:

openssl.exe pkcs12 –in test_b.pfx –out test_b.pem

- the p7b file contained three certificates that looked like cert authorities, so I used the other file that looked like it contained client certificates.

What is the difference between using pkcs7 and pkcs12?
 
Another question - if I want to create a CA bundle of more than one certificate in a PEM file, what structure should it take?

Is it ok to have
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----

multiple times in one .pem file?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top