RE: [PHP] Please, I need help with curl and php
| From: | Wei, Alice J. | Date: | Tue, 29 Jul 2008 17:10:07 +0000 |
| Subject: | RE: [PHP] Please, I need help with curl and php | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-277427@lists.php.net to get a copy of this message | ||
Thanks for your time
As you can see, I´m trying to connect to a web site and:
* I need to use a cert. This cert is pem type
* I go out from my net throw a proxy with an user and pass
* I need to collect cookies
And the most important, I need to catch the answer from this script.
The script that I send you has a lot of variables, but I'm replacing it with the real value in
mi app.
the problem is that I don't know if my code is correct, and why I´m receibing the error
message:
Error 58: unable to use client certificate (no key found or wrong pass phrase?)
I know that my password is correct, so I think that the problem is related to my php code .
Since I don't see the code, my guess is that there is something going on with the snippet
regarding the error above.
There is an article online regarding API errors and talks about the same error you are coming
across:
Unable to use client certificate (no key found or wrong pass phrase?)
You are receiving this error becuase you have the wrong path for the PEM file. Also make sure
you upload the PEM file in ASCII format for UNIX servers.
On a UNIX server the path for the PEM file should look something like this:
$myorder["keyfile"] = "/home/htdocs/www/linkpoint/123456.pem";
On a WINDOWS server the path should look like this:
$myorder["keyfile"] = "c:\\inetpub\\wwwroot\\linkpoint\\123456.pem";
If you can not determine the path for the PEM file you can use the following code: (make sure
the PEM file is in the same directory as your PHP file)
$myorder["keyfile"] = realpath("123456.pem");
I hope this helps.
Alice
2008/7/29 Wei, Alice J. <ajwei@indiana.edu<mailto:ajwei@indiana.edu>>
Hi, I´m making a little application with php and curl, but I´m a newby with
curl.
Please help me with the next script.
I used to use this in order to make a connection with an specific site on
the console ms-dos (windows), how can i translate this into php code?
curl -x proxy_url:proxy_port -U proxy_user:proxy_pass --cert
cert.pem:cert_pass --cert-type PEM -k -c cookie.txt -d
"txtUser=user_loguin&txtPass=pass_loguin"
url_required<https://renat.segob.gob.mx/AppRNT/validacion/valida.php>
I tried with this, but it doesn't work fine
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, $f_path);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_PROXY, $proxurl);
curl_setopt($ch,CURLOPT_PROXYPORT,$proxport);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_CAINFO, $fichero);
curl_setopt($ch, CURLOPT_PROXYUSERPWD,
"'".$proxyu.":".$proxyp."'");
curl_setopt($ch,CURLOPT_SSLCERT,$fichero);
curl_setopt($ch,CURLOPT_SSLCERTTYPE, "pem");
curl_setopt($ch,CURLOPT_SSLCERTPASSWD,$pcert);
curl_setopt($ch,CURLOPT_USERPWD,"'".$usr.":".$pwd."'");
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
curl_setopt($ch, CURLOPT_HEADER, 1);
$HTTP_Response1 = curl_exec($ch);
Thanks and recards
Have you tried taking $HTTP_Response1 out and just execute the curl by doing curl_exec($ch)?
It seems to me that it is initiating, but it is not calling or executing anything.
This is what I have when I use curl
// grab URL and pass it to the browser
curl_exec($ch);
// close cURL resource, and free up system resources
curl_close($ch);
Hope this helps.
Alice
======================================================
Alice Wei
MIS 2009
School of Library and Information Science
Indiana University Bloomington
ajwei@indiana.edu<mailto:ajwei@indiana.edu>