Curl OpenSSL error 141A318A tls_process_ske_dhe:dh key too small

Curl OpenSSL error 141A318A tls_process_ske_dhe:dh key too small

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

Stefan Bogdanescu

Founder & Senior Architect

Curl OpenSSL error 141A318A tls_process_ske_dhe:dh key too small

When an IONOS server update breaks your outbound HTTPS requests, the culprit is almost always a mismatch in cryptographic standards rather than a broken PHP installation. You are seeing error:141A318A:SSL routines:tls_process_ske_dhe:dh key too small because OpenSSL has tightened its security policies for Diffie-Hellman (DH) key exchanges. Modern TLS versions, particularly those enforced by strict intermediaries or updated server configurations, require DH groups to be at least 2048 bits long. If the remote server you are hitting is still using a legacy DH group smaller than this threshold, OpenSSL will refuse the connection immediately to prevent potential downgrade attacks.

The fact that disabling SSL verification in your curl call did not solve the issue confirms that this is not a certificate trust problem. The error occurs during the handshake phase before any application data is transferred. Your current setup disables peer and host verification:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

While these flags allow you to bypass certificate validation errors (like expired certs or self-signed certificates), they do nothing to influence the mathematical requirements of the DH key exchange. The tls_process_ske_dhe function specifically checks the size of the DH parameters. If the remote server presents a group with fewer than 2048 bits, OpenSSL throws this fatal error regardless of your verification settings.

Switching to file_get_contents() behaves identically because PHP's underlying SSL stack for cURL and standard file functions relies on the same OpenSSL libraries. The warning you received is simply a different presentation of the same cryptographic rejection.

Why This Happens After Provider Updates

Your hosting provider, IONOS, likely updated their server software (e.g., moving from an older OpenSSL version to 1.1.1 or a newer release). Older versions of OpenSSL were more lenient and would accept DH keys as small as 512 or 1024 bits. Newer versions default to rejecting anything below 2048 bits unless explicitly told otherwise via the SSL_OP_SINGLE_ECDH_USE or similar legacy options, which are deprecated for security reasons.

If you cannot modify the remote server's configuration (which you typically cannot do when calling a third-party API), you have two viable paths forward.

Option 1: Force Legacy Security (Not Recommended)

Technically, you can attempt to override OpenSSL's default behavior by enabling legacy DH usage, but this is generally considered insecure and often blocked by the server itself if it enforces strict TLS versions. You might see documentation suggesting adding CURLOPT_SSL_OPTIONS with CURLOPT_SSL_OP_ALL, but modern OpenSSL builds often strip these options entirely or ignore them for security-critical checks like DH size.

// Do not enable this unless you fully understand the risk
curl_setopt($ch, CURLOPT_SSL_OPTIONS, CURLSSLOPT_LEGACY_TLS); 

Even if this flag works in your specific OpenSSL build, it exposes your application to vulnerabilities that modern TLS mitigates. If the remote server rejects the connection for non-crypto reasons after the handshake, this is a red herring. However, since the error explicitly states dh key too small, this is the root cause.

Option 2: Switch Algorithms (The Correct Solution)

The robust solution is to avoid Diffie-Hellman entirely if the remote server supports it, or to ensure you are using ECDHE (Elliptic Curve Diffie-Hellman Ephemeral) which offers comparable security with much smaller key sizes. However, in many cases of this specific error, the remote API might be hardcoded to use static DH groups that are now considered insecure.

If you control the code and cannot change the server, you must check if the API documentation allows for a different transport mechanism or if the provider is deprecating their endpoint. If the remote service is not updated and forces a small DH key, your application effectively needs to stop using HTTPS with that specific endpoint until the service owner updates their crypto configuration.

Checking Your Environment

Before concluding the remote server is at fault, verify your local OpenSSL version and its default behavior:

openssl version -a

If you are on a very recent version of OpenSSL (1.1.1+), it enforces strict DH checks by default. To confirm the specific error source, enable verbose output in your cURL call:

curl_setopt($ch, CURLOPT_VERBOSE, true);
// ... other options
curl_exec($ch);

The debug output will reveal if the handshake fails immediately during TLS_CHANGE_CIPHER_SPEC or TLS_HANDSHAKE. If you see the DH key exchange failing, the remote server is sending an invalid group.

In summary, this error is not a PHP configuration issue nor a cURL bug; it is a cryptographic incompatibility caused by your host upgrading OpenSSL to reject weak encryption parameters. The only sustainable fix is for the target API provider to upgrade their TLS configuration to use DH groups of at least 2048 bits or switch to ECDHE key exchange.

Our network