A problem occurred somewhere in the SSL/TLS handshake

A problem occurred somewhere in the SSL/TLS handshake

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

A problem occurred somewhere in the SSL/TLS handshake

When cURL works perfectly over HTTP but fails immediately on HTTPS with error code 35, "A problem occurred somewhere in the SSL/TLS handshake," you are likely facing an environmental mismatch rather than a logic error in your application code. The fact that this worked on a previous shared hosting environment and broke on your current development server suggests a shift in how the underlying OpenSSL library is configured or which certificates are available to the system.

Disabling peer verification by setting CURLOPT_SSL_VERIFYPEER to false is generally a bad idea for production, but even attempting to do so without changing the return value implies that the connection itself isn't establishing. Error 35 specifically indicates that the SSL/TLS protocol negotiation failed before any data was successfully exchanged. This usually happens when the client and server cannot agree on a cipher suite or when the handshake is interrupted by certificate validation failures that standard configuration tweaks don't resolve.

The most common culprit in this scenario is the absence of a valid Certificate Authority (CA) bundle. While you have tried downloading individual certificates for the target resource, modern TLS handshakes often require a broader trust store to validate the server's chain of trust. If your development server's OpenSSL library points to an empty or outdated CA file, it cannot verify the server's certificate, causing the handshake to abort immediately.

To resolve this, you must ensure that curl can locate a current list of trusted root certificates. Instead of manually downloading and pointing CURLOPT_CAINFO to a single certificate file, it is best practice to use the system-wide CA bundle or explicitly load a modern one like Mozilla's ca-bundle.crt. You can verify if the system has the bundle available by checking for /etc/ssl/certs/ca-certificates.crt or similar paths depending on your Linux distribution.

If you need to specify a custom path, ensure that the file contains the full chain of trust, not just the leaf certificate. The following example demonstrates how to explicitly load a CA bundle:

$ch = curl_init('https://google.com');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_CAINFO, '/path/to/ca-bundle.crt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);

Another frequent issue arises from OpenSSL library versions. Your development server might be running a version of PHP or OpenSSL that is incompatible with the cipher suites the remote server requires, or vice versa. If you are on a legacy shared hosting environment where this code previously worked, those servers often had more permissive TLS configurations or bundled older certificates that happened to match the target's requirements by chance. On a fresh development server, strict security defaults may be in place, causing the handshake to fail if the local trust store is incomplete.

You should also verify that OpenSSL is actually enabled and functional within your PHP environment. Running php -m should list openssl, but you must also ensure that the specific extensions required for TLS are loaded. Additionally, check the error logs of your web server or CLI output with CURLOPT_VERBOSE enabled to see exactly where the handshake breaks down. The verbose output will reveal if the error stems from a missing CA certificate, an unsupported protocol version, or a specific cipher suite mismatch.

Finally, consider that the previous shared hosting environment might have had pre-installed certificates that were not present on your current VPS or local machine. In such cases, installing the necessary packages, such as ca-certificates on Debian/Ubuntu systems, is essential before expecting HTTPS requests to succeed without manually managing every certificate file.

Our network