1

I have setup a custom Magento Rest Api at the endpoint: "https://domain-name.de/rest/V1/wawi". This Api just returns a simple json string. Have tested my Api with Postman application -> works fine.

The problem occurs, when I test it in PHP script:

 $curl = curl_init();

 curl_setopt_array($curl, array(
 CURLOPT_URL => "https://domain-name.de/rest/V1/wawi",
 CURLOPT_RETURNTRANSFER => true,
 CURLOPT_ENCODING => "",
 CURLOPT_MAXREDIRS => 10,
 CURLOPT_TIMEOUT => 30,
 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
 CURLOPT_SSL_VERIFYPEER => 0,
 CURLOPT_SSL_VERIFYHOST => 0,
 CURLOPT_CUSTOMREQUEST => "POST",
 CURLOPT_POSTFIELDS => "{\"p\":\"test\"}",
 CURLOPT_HTTPHEADER => array(
 "cache-control: no-cache",
 "content-type: application/json",
 ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
 echo "cURL Error #:" . $err;
} else {
  echo $response;
}

RESULT:

cURL Error #:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

Any ideas on how to solve this issue ?

EDIT Just checked my magento server is using "OpenSSL 1.0.1e-fips 11 Feb 2013 openssl version number: 268439647" and my client is using "OpenSSL 1.0.1k 8 Jan 2015 openssl version number: 268439743"

2 Answers 2

0

please add CURLOPT_SSLVERSION =>3

3
  • Thx for the reply. Added and got new error message: cURL Error #:error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number Jan 10, 2018 at 13:02
  • Tried also with 2, message: cURL Error #:OpenSSL was built without SSLv2 support Jan 10, 2018 at 13:03
  • magento ver 1.9.2.3,I am work with REST API in POSTMAN, i have all oAuth 1.0 details like Consumer Key,Consumer Secret,Access Token,Token Secret. Now i moved to oAuth 2.0, how can i get my all oAuth 2.0 details? @Nalin Savaliya
    – zus
    Oct 30, 2018 at 6:34
0

I don't see any reason for using the following lines:

 CURLOPT_ENCODING => "",
 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
 CURLOPT_ENCODING => "",

Try removing all these lines, or, if you prefer, test removing one by one.

1
  • Let me know if this solves you issue. If negative I will take a deeper analysis. Jan 2, 2022 at 21:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.