Configuring PHP OpenSSL on Windows

This section provides a tutorial example on how to install and configure the PHP OpenSSL module on Windows systems. PHP OpenSSL is provided as a DLL file called php_openssl.dll.

If you want to write your own PHP program to communicate with an HTTPS Web server, you should install a PHP module to help you. Currently, the best PHP module for HTTPS communication is the OpenSSL module.

Here what I did to install and configure the OpenSSL module on my Windows system:

1. Make sure I have PHP installed properly:

herong> \local\php\php -version

PHP 7.0.2 (cli) (built: Jan  6 2016 13:05:11) ( ZTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies

2. Make sure the OpenSSL module DLL file is included in the PHP installation:

herong> dir \local\php\ext\php_openssl.dll

01/06/2016  02:01 PM            91,136 php_openssl.dll

3. Create the PHP configuration file, \local\php\php.ini, if it does not exist:

herong> copy \local\php\php.ini-production \local\php\php.ini

        1 file(s) copied.

4. Enable the OpenSSL module by editing the configuration file with a text editor. You need to remove the comment maker (;) on two configuration lines:

...

; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = "ext"

...
extension=php_openssl.dll

...

I think I am ready to test the PHP OpenSSL module. See the next tutorial.

Table of Contents

 About This Book

 Introduction of PKI (Public Key Infrastructure)

 Introduction of HTTPS (Hypertext Transfer Protocol Secure)

 Using HTTPS with Google Chrome

 Using HTTPS with Mozilla Firefox

 HTTPS with Microsoft Edge

 Using HTTPS with Apple Safari

 HTTPS with IE (Internet Explorer)

 Android and Server Certificate

 iPhone and Server Certificate

 Windows Certificate Stores and Console

 RDP (Remote Desktop Protocol) and Server Certificate

 macOS Certificate Stores and Keychain Access

 Perl Scripts Communicating with HTTPS Servers

PHP Scripts Communicating with HTTPS Servers

Configuring PHP OpenSSL on Windows

 Testing OpenSSL with file_get_contents()

 OpenSSL Configuration Errors

 SSL Context Options for OpenSSL

 Asking OpenSSL to Verify Server's Certificate

 OpenSSL Failing to Verify Server's Certificate

 Multiple CA Certificates in a Single File

 Testing OpenSSL with fopen()

 Testing OpenSSL with fsockopen()

 Adding CA Certificates for the PHP Engine

 Testing OpenSSL with stream_socket_client()

 Java Programs Communicating with HTTPS Servers

 .NET Programs Communicating with HTTPS Servers

 CAcert.org - Root CA Offering Free Certificates

 PKI CA Administration - Issuing Certificates

 Comodo Free Personal Certificate

 Digital Signature - Microsoft Word

 Digital Signature - OpenOffice.org 3

 S/MIME and Email Security

 PKI (Public Key Infrastructure) Terminology

 Archived Tutorials

 References

 Full Version in PDF/EPUB