We need the relevant PHP module to communicate with an HTTPS or TLS server. This tutorial provides all the steps required to configure the OpenSSL module of PHP on Windows for communication over HTTPS or TLS protocols.
Step 1 - Verify Module
First of all, we will verify whether the SSL module is already installed and enabled by analyzing the output of the phpinfo function.
Write a program having the content as shown below. I have saved the file as info.php.
Now execute it on the console using the PHP executable as shown below.
# Execute the php file
gzip compression => enabled
bzip2 compression => disabled (install ext/bz2)
OpenSSL support => disabled (install ext/openssl)
We can see that the OpenSSL support is disabled for the PHP installed on the system. The output of the same program on the browser is shown in Fig 1.
Step 2 - Configure Module
In order to continue with this step, make sure that the php_openssl.dll is present within the ext directory of your PHP installation.
Now update the php.ini file as shown below.
Save the file and again run the info.php on the console. You should see the output as shown below.
OpenSSL support => enabled
OpenSSL Library Version => OpenSSL 1.1.1a 20 Nov 2018
OpenSSL Header Version => OpenSSL 1.1.1a 20 Nov 2018
Openssl default config => C:\usr\local\ssl/openssl.cnf
If you run info.php in the browser, it should look like the one as shown in Fig 2. Make sure to restart Apache Web Server to reflect the changes.
This is how we can enable the OpenSSL module of PHP on Windows. We can communicate over the HTTPS or TLS protocols after enabling this module.