TLS 1.2 not working in cURL

TLS 1.2 not working in cURL

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

Stefan Bogdanescu

Founder & Senior Architect

TLS 1.2 not working in cURL

When you encounter an SSL23_GET_SERVER_HELLO:tlsv1 alert internal error from a server, it almost always indicates a protocol mismatch or a fundamental incompatibility between the client's SSL/TLS stack and what the server expects. The specific context here—using OpenSSL 0.9.8b with cURL 7.24.0 running on PHP 5.3—is the critical detail that explains why standard debugging flags like CURLOPT_SSL_VERIFYPEER or CURLOPT_SSL_VERIFYHOST won't resolve the issue.

The error message provided is technically accurate but can be misleading if you interpret it solely as a certificate validation failure. While disabling peer verification might suppress the handshake error temporarily, doing so exposes your application to man-in-the-middle attacks and violates security best practices. The real culprit lies in the age of the OpenSSL library being used.

OpenSSL 0.9.8b is an ancient version released over a decade ago. Modern web servers have largely deprecated support for TLS 1.2 and, more recently, TLS 1.3, requiring clients to use updated cryptographic algorithms that simply do not exist in the 0.9.8 codebase. Specifically, this version lacks support for the cipher suites required for modern TLS 1.2 handshakes and does not understand the TLS_EMPTY_POST_HANDSHAKE_AUTH extension or other extensions mandated by current security standards.

In your PHP script, you are attempting to force a connection using:

curl_setopt ($setuploginurl, CURLOPT_SSLVERSION, 'CURL_SSLVERSION_TLSv1_2');

This option tells the cURL library to negotiate a TLS 1.2 session. However, if the underlying OpenSSL library (0.9.8b) does not implement the necessary TLS 1.2 handshake logic, cURL cannot complete the negotiation regardless of the flag you pass. The server sends a tlsv1 alert internal error because it receives an incomplete or malformed Client Hello message from your client stack.

The combination of OpenSSL 0.9.8b and cURL 7.24.0 creates a hard ceiling for security. You cannot upgrade just the cURL library version without upgrading the underlying OpenSSL package first; cURL relies on the system's OpenSSL installation to perform cryptographic operations. To resolve this, you must update your system's OpenSSL to at least version 1.0.2, and preferably 3.x, which provides robust support for TLS 1.2 and 1.3.

Once the OpenSSL library is updated, the existing code logic usually remains valid, provided that CURLOPT_SSLVERSION is set correctly. In newer versions of cURL (7.68+), string constants like 'TLSv1_2' are preferred over the deprecated numeric values or specific string aliases found in older documentation.

Additionally, be aware that older PHP versions like 5.3 may have limitations in how they pass SSL options to the underlying libcurl. While your current setup attempts to use CURLOPT_SSLVERSION, ensure that the version string matches exactly what the cURL build expects. If you are on a legacy system where upgrading OpenSSL is impossible, you may need to compile a static build of cURL linked against a newer, portable version of OpenSSL (such as BoringSSL or a specific OpenSSL release) to bypass the system's outdated libraries.

Finally, remember that setting CURLOPT_SSL_VERIFYPEER to 0 is a temporary workaround for testing connectivity only, not for production use. If you disable this flag, the error might disappear, but your application will be vulnerable to intercepting traffic. The correct path forward is always to upgrade the cryptographic stack, not to lower security standards.

Our network