Answer the question
In order to leave comments, you need to log in
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);
?>
Answer the question
In order to leave comments, you need to log in
Discussion in the comments
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false)
? Or here (StOw) maybe something usefulcurl_setopt ($ch, CURLOPT_CAINFO, dirname(__FILE__)."/cert.pem");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question