curl-and-php
Please Help
Date: Thu, 1 Dec 2005 07:05:11 -0800 (PST)
Hi all,
I've been trying to get this work for awhile, and still no luck.
I want to send XML string to a server that require a .PEM file.
But I never get a response from the server and get error : (58) unable to set certificate file (wrong password?).
I've tried using
curl_setopt ($ch, CURLOPT_CAINFO, "c:\\windows\\ca-bundle.crt");
curl_setopt ($ch, CURLOPT_CAPATH, "c:\\windows\\ca-bundle.crt");
curl_setopt ($ch, CURL_CA_BUNDLE, "c:\\windows\\ca-bundle.crt");
but still no luck.
If I commented out the curl_setopt ($ch, CURLOPT_SSLCERT, $cert) line, I got a response from the server saying I can't access it since there's no .pem file.
So, is this an error from my server or from the other server? And what do I need to do to eliminate this problem..
This is my first time using curl, so any help would be appreciated.
I'm using Windows XP + apache + php.
Thanks.
Here's the code:
$xml = "<order>...</order>"; # xml string
$host = "secure.linkpt.net";
$port = 1129;
$cert = ".\key.pem"; # change this to the name and location of your certificate file
$hoststring = "https://".$host.":".$port."/LSGSXML";
# use PHP built-in curl functions
$ch = curl_init ();
curl_setopt ($ch, CURLOPT_URL,$hoststring);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $xml); # the string we built above
curl_setopt ($ch, CURLOPT_SSLCERT, $cert);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
# curl_setopt ($ch, CURLOPT_CAINFO, "c:\\windows\\ca-bundle.crt");
# curl_setopt ($ch, CURLOPT_CAPATH, "c:\\windows\\ca-bundle.crt");
# curl_setopt ($ch, CURL_CA_BUNDLE, "c:\\windows\\ca-bundle.crt");
curl_setopt ($ch, CURLOPT_VERBOSE, 1); // optional - verbose debug output
// not for production use
# send the string to LSGS
$result = curl_exec ($ch);
if (curl_errno($ch))
{
print curl_errno($ch);
print curl_error($ch);
} else
{
curl_close($ch);
}
if (strlen($result) < 2) # no response
{
$result = "<r_error>Could not execute curl.</r_error>";
}
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2005-12-01