cURL isn't working, returning an error -
i'm trying pass variables through url generate xml data, pass variables , grab xml data curl , bring webpage can parse data , use 1 of elements attribute values , put php variable display on page.
so seems i've been @ forever have following code, (fyi. put 'password' in place of real password. 'shipper number in here' in place of real shipper number , 'token here' in place of real token thread)
$xml = ' weight_system="imperial" shipper_number="shipper number in here" destination_postal_code="'.$data5['zip'].'" service_type="1" '; $xml2 = ' total_pieces="'.$value.'" total_weight="'.$weight.'" '; $token = 'token here'; $base_url = 'https://www.shippingco.com/xml/ratingxml.jsp'; $request_url = $base_url . '?' . http_build_query(array( 'shipment' => '<shipment ' . $xml . '><total ' . $xml2 . '/></shipment>', 'token' => $token )); // curl resource $curl = curl_init(); // set options - passing in useragent 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, '1'); curl_setopt($curl, curlopt_ssl_verifypeer, '1'); curl_setopt($curl, curlopt_cainfo, '../cert/ca.crt'); curl_setopt($curl, curlopt_sslcert, '../cert/mycert.pem'); curl_setopt($curl, curlopt_sslkey, '../cert/mykey.pem'); curl_setopt($curl, curlopt_sslcertpasswd, 'password'); // send request & save response $resp $result = curl_exec($curl); echo curl_error($curl); // close request clear resources curl_close($curl);
which produces:
error: unable use client certificate (no key found or wrong pass phrase?)
i've tried call paths using getcwd().'../cert/...', getcwd().'/cert/...', 'public_html/cert/...' , checking see if path works using code,
if (file_exists('../cert/ca.crt')) { echo 'yes'; } else { echo 'no'; }
and file_exists returns yes when calling ../cert/ca.crt i'm using path in curl code. i'm still not sure else going wrong.
i purchased ssl , dedicated ip address encase you're wondering. have rsa key, ssl cert, ca bundle , password , saved them file names , formats listed above in own directory called cert. if saved them wrong file format or wrong extension, please let me know. time.
directory structure:
public_html (root) cert (dir inside public_html) ca.crt (file inside cert) mycert.pem (file inside cert) mykey.pem (file inside cert) secure (dir inside public_html) shopping.php (file inside secure)
Comments
Post a Comment