Using TLS 1.2 with PHP CURL Forcefully

You can add the following code to your curl requests to use TLS 1.2. Use 6 as the value of CURLOPT_SSLVERSION forces cURL to use TLS 1.2. Below is the sample code to force use tls 1.2 with php curl:

For the example, I am using a sample script from our another articlesubmitting JSON data with cURL and PHP. In that script, we will add code to forece use of tls 1.2. Below is the sample script:

You can execute above script in webbrowser or from the command line interface.


In this tutorial, you have learned to use tls 1.2 with PHP/cURL forcefully.