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"

asked Jan 10, 2018 at 12:25

2 Answers 2

0

please add CURLOPT_SSLVERSION =>3

answered Jan 10, 2018 at 12:42
3
  • Thx for the reply. Added and got new error message: cURL Error #:error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number Commented Jan 10, 2018 at 13:02
  • Tried also with 2, message: cURL Error #:OpenSSL was built without SSLv2 support Commented 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 Commented 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.

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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.