Jump to content

Recommended Posts

is this code setup right?

// Get cURL resource
$curl = curl_init();
// Set some options - we are passing in a useragent too here
curl_setopt($curl, CURLOPT_URL, $request_url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($curl, CURLOPT_CAINFO,  '/public_html/cert/ca.crt');  //(<--- path to CA bundle)
curl_setopt($curl, CURLOPT_SSLCERT, '/public_html/cert/mycert.pem');  //(<--- path to SSL certificate)
curl_setopt($curl, CURLOPT_SSLKEY, '/public_html/cert/mykey.pem');  //(<--- path to RSA key)
curl_setopt($curl, CURLOPT_SSLCERTPASSWD, 'password');
// Send the request & save response to $resp
$result = curl_exec($curl);
echo curl_error($curl);
// Close request to clear up some resources
curl_close($curl);
 
I keep getting this error when executing this code,
 
unable to use client certificate (no key found or wrong pass phrase?)
Edited by andy1212
Link to comment
https://forums.phpfreaks.com/topic/280557-is-this-set-up-right/
Share on other sites

As I posted in the other thread you created for this exact same problem, which I've deleted because I don't want anyone else to make the same mistake of replying to one thread telling you to post code and then coming over here to discover it's the same question but this time with code,

Programming tip #1: if you get an error message and don't know what it means, Google it.

Looks like you need check the file permissions and that you have the right path to it in your script.

 

Otherwise post the code.

Turns out it was the "right path to it".

 

The path to the file is not "/public_html/cert/*" because I doubt you have a public_html directory at the root of your drive.

Next I would tell you what path to use except there's a problem: those files are web-accessible. That's horribly bad. Move them somewhere else not in or under the public_html directory. Then figure out what their actual paths are (spoiler: probably starts with something like "/home/andy1212") and substitute those into your code.

would I use all three lines or just one or two of them.

 

 

curl_setopt($curl, CURLOPT_CAINFO,  '/home/ssl/certs/website.com.crt');
curl_setopt($curl, CURLOPT_SSLCERT, '/home/ssl/certs/website.com.crt');
curl_setopt($curl, CURLOPT_SSLKEY, '/home/ssl/certs/mykey.pem');
 
like do I have to give a path to the RSA key, CA bundle and SSL cert or just the SSL or just the CA bundle. There are a number of files I found on in the home/ssl/certs/ directory I found on the server and I'm not sure which ones to give paths to and where to put them in the code above. Some of the files have a .old.(a long number here) and I don't know if I should link to those because it says old, maybe those are the SSL files I had before I purchased this new SSL. I did Google the error message but couldn't find anyone that had a similar problem to what I'm trying to do. 
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.