M
M
machno2014-12-16 17:43:53
PHP
machno, 2014-12-16 17:43:53

How to make an https request using cURL?

I'm trying to make a request to a site that verifies my certificate. Does not exceed.

<?php
$url = 'https://payments.mtsbank.ru/ecomm/MerchantHandler';
 
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, '2');
curl_setopt($ch, CURLOPT_SSLCERT, './cert.pem');
curl_setopt($ch, CURLOPT_SSLKEY, './key.pem');
curl_setopt($ch, CURLOPT_SSLKEYPASSWD, 'password');
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result = curl_exec ($ch);
 
echo $result;
if ($result == NULL) {
echo "Error:\n";
echo curl_errno($ch) . " - " . curl_error($ch) . "\n";
}
 
curl_close ($ch);
?>

cURL swears Error: 58 - Unable to load client key -8178.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Appp Zooo, 2014-12-16
@ikeagold

Discussion in the comments

curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false)
? Or here (StOw) maybe something useful
curl_setopt ($ch, CURLOPT_CAINFO, dirname(__FILE__)."/cert.pem");

B
Bugolos, 2018-11-09
@Bugolos

Kind! I also faced such problem. Maybe it's the PHP version or server settings, since the same script refused to work on PHP5, but on PHP7 everything works fine - all this was tested on the same server

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question