61044

SSL Connection Error even when VERIFYPEER, VERIFYHOST disabled

Question:

I am at present building a script to fulfil some SSL curl requests, however I have had no luck in fulfilling these. All I receive from <strong>curl_error()</strong> is a simple "<strong>SSL Connection Error"</strong> string... This is not helpful at all. I have tried inserting a valid self-signed certificate, disabled verification <strong>entirely</strong> (as seen in the code below), and a million and one other configuration variances, but I consistently get this error. Where am I going wrong?

function request($url, $data, $method) { $curlSession = curl_init(); $headers = [ 'Authorization: Basic ' . 'REDACTED' ]; // Set the URL curl_setopt($curlSession, CURLOPT_URL, $url); curl_setopt($curlSession, CURLOPT_HTTPHEADER, $headers); curl_setopt($curlSession, CURLOPT_HEADER,1); switch ($method) { case 'POST': curl_setopt($curlSession, CURLOPT_POST, 1); curl_setopt($curlSession, CURLOPT_POSTFIELDS, $data); case 'PUT': curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); curl_setopt($curlSession, CURLOPT_POSTFIELDS, $data); } // Return it direct, don't print it out curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, 1); // Set correct port curl_setopt($curlSession, CURLOPT_PORT, 80); // This connection will timeout in 30 seconds curl_setopt($curlSession, CURLOPT_TIMEOUT, 30); // Disable SSL Checking as not working curl_setopt($curlSession, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curlSession, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curlSession, CURLINFO_HEADER_OUT, true); // Send the request and store the result in an array $rawResponse = curl_exec($curlSession); // Check that a connection was made if (curl_error($curlSession)) { $info = curl_getinfo($curlSession); $curlError = curl_error($curlSession); // Close the cURL session curl_close($curlSession); print_r($info); print($curlError); // If it wasn't... return false; } $info = curl_getinfo($curlSession); $httpStatus = curl_getinfo($curlSession, CURLINFO_HTTP_CODE); // Close the cURL session curl_close($curlSession); return $rawResponse; }

Answer1:

Try to add:

curl_setopt($curlSession, CURLOPT_SSLVERSION, 3); // FIX SSL23_GET_SERVER_HELLO error

see <a href="https://sourceforge.net/p/curl/bugs/1037" rel="nofollow">https://sourceforge.net/p/curl/bugs/1037</a>

Recommend

  • Why does trailing backslash followed by quote behave so strangely in cmd?
  • Single-function comparison of Union values
  • ASP.NET Boilerplate MVC 5.x template fails to start
  • How to properly remove redundant components for Scikit-Learn's DPGMM?
  • Re-implementing lists with closures in scheme
  • Negotiate 404 with SignalR 2.2.1 in Asp.net core application
  • DownloadString returns a 404 Error: Site needs a User-Agent Header
  • Is it necessary to have typing/definiton files for every JS library you use in typescript?
  • Efficiency of passing a struct to a function without instantiating a local variable
  • quick sort improvement using median of three robert sedwick
  • OpenCV detect square with difficult background
  • R: Find the Variance of all Non-Zero Elements in Each Row
  • How to render maps within ng-hide divs using ngMap without getting a gray rectangle
  • Tagging columns as Categorical in Spark
  • PHP set_time_limit no effect
  • MySQL Amazon RDS: Lock Wait timeout exceeded
  • VS 2015, C# 6, MVC5, Roslyn — 502 gateway errors on Azure web app
  • readPNG error: ggmap and Stamen Maps
  • Php Curl HTTP POST REQUEST set custom header with nested key value pairs
  • Is it possilbe to automatically submit a php form
  • How do I use cURL & PHP to spoof the referrer?
  • 403 forbidden error while sending messages to facebook connector through Unification Engine API
  • Content-Length header not returned from Pylons response
  • How to apply VCL Styles to DLL-based forms in Inno Setup?
  • Trying to switch camera back to front but getting exception
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • Circular dependency while pushing http interceptor
  • AngularJs get employee from factory
  • Free memory of cv::Mat loaded using FileStorage API
  • How to set the response of a form post action to a iframe source?
  • Angular 2 constructor injection vs direct access
  • embed rChart in Markdown
  • Change div Background jquery
  • Linking SubReports Without LinkChild/LinkMaster
  • Can't mass-assign protected attributes when import data from csv file
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • Programmatically clearing map cache
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • How can I use `wmic` in a Windows PE script?
  • Unable to use reactive element in my shiny app