How can one handle the error "SSL read: error:14094418:SSL routines:SSL3_READ_BYTES:tlsv1 alert unknown" in PHP cURL?

The error "SSL read: error:14094418:SSL routines:SSL3_READ_BYTES:tlsv1 alert unknown" occurs when there is an issue with the SSL/TLS handshake during a cURL request. To solve this issue, you can force cURL to use a specific version of SSL/TLS, such as TLSv1.2, by setting the CURLOPT_SSLVERSION option in the cURL request.

// Initialize cURL session
$ch = curl_init();

// Set cURL options
curl_setopt($ch, CURLOPT_URL, 'https://example.com');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);

// Execute cURL session
$response = curl_exec($ch);

// Check for errors
if(curl_errno($ch)){
    echo 'Curl error: ' . curl_error($ch);
}

// Close cURL session
curl_close($ch);

// Handle response
echo $response;