faqts : Computers : Programming : Languages : PHP : Not Quite PHP : Ecommerce

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

93 of 128 people (73%) answered Yes
Recently 4 of 10 people (40%) answered Yes

Entry

How can PHP make a SSL encrypted post to a transaction server?
Need I to add --cert [cert-path] ?
When I use this way, my return number is zero but other side get ERROR 403. How should I do?
how should I do to post data to a server which ask the client must present a valid certificate ?
how should I do to post data to a server which ask the client must present a valid certificate ?
how should I do to post data to a server which ask the client must present a valid certificate ?

Aug 7th, 2001 23:56
Daniel Stenberg, Matt Allen, Gary Chen, cURL is now at http://curl.haxx.se/


PHP3 cannot not talk SSL nativley, therefore to make an SSL post you 
need to enlist the help of a little app called cURL.
PHP4 is capable of doing this natively using libcurl as a module, see 
the PHP4 online manual link.
cURL is a command line driven app that accepts data and simulates 
posting a form to an SSL website.  The data returned depends on the 
server we are posting to, although usually it is returned as a comma 
serperated line. cURL is called via the exec() command in PHP.
Here is an example of a line that calls cURL.
exec("/usr/local/bin/curl -m 120 -d \"$data\" https://$URL 
-L",$return_message_array, $return_number);
** NOTE ** The above line must NOT contain any line breaks, make sure
its all on one line.
-m is the timeout in seconds
-d is the data you wish to post ($data="var=value=value1")
$URL is the https page you are posting to,
The way i walk though the results is:
for ($i = 0; $i < count($return_message_array); $i++  ) {
	$results = $results.$return_message_array[$i];
}
$results then contains all the data that was returned from the server.
Note that if you use PHP4, you really SHOULD use the CURL module instead
as then you can do everything this with native PHP calls instead. Less
overhead and faster operations.
To use curl with a client certificate you use -E on the command line, or
 CURLOPT_SSLCERT + CURLOPT_SSLCERTPASSWD from PHP.
To use curl to verify your servers certificate, you use the --cacert on
the commandline or CURLOPT_CAINFO from PHP.
Just make sure that your certificates is converted to PEM format before
you try using them like this.