Enabling the OpenSSL in XAMPP

PhpSslXampp

Php Problem Overview


I spent three hours but I did not find anything; I'm unable to connect to a SSL enabled server. I want to list what i did:

First checked my PHP extensions directory was in order; extension wasn't there, php_openssl.dll

Then I opened my php.ini file but I could not see any extension=php_openssl.dll line to uncomment.

Also, I searched on Google and saw people with the same problem. http://www.apachefriends.org/f/viewtopic.php?p=162623

However, I also have

OPENSSL_CONF C:/xampp/apache/bin/openssl.cnf 
...
openssl
OpenSSL support enabled 
OpenSSL Library Version OpenSSL 0.9.8l 5 Nov 2009 
OpenSSL Header Version OpenSSL 0.9.8l 5 Nov 2009

no lines . What should I do? Please share your suggestions.

Php Solutions


Solution 1 - Php

Yes, you must open php.ini and remove the semicolon to:

;extension=php_openssl.dll

If you don't have that line, check that you have the file (In my PC is on D:\xampp\php\ext) and add this to php.ini in the "Dynamic Extensions" section:

extension=php_openssl.dll

Solution 2 - Php

[PHP_OPENSSL]
extension=php_openssl.dll

This is the answer.

Solution 3 - Php

Things have changed for PHP > 7. This is what i had to do for PHP 7.2.

Step: 1: Uncomment extension=openssl

Step: 2: Uncomment extension_dir = "ext"

Step: 3: Restart xampp.

Done.

Explanation: ( From php.ini )

If you wish to have an extension loaded automatically, use the following syntax:

extension=modulename

Note : The syntax used in previous PHP versions (extension=<ext>.so and extension='php_<ext>.dll) is supported for legacy reasons and may be deprecated in a future PHP major version. So, when it is possible, please move to the new (extension=<ext>) syntax.

Special Note: Be sure to appropriately set the extension_dir directive.

Solution 4 - Php

I use xampp. Beforehand I tried the example file "test_smtp_gmail_basic.php" in phpMailer (you can download phpMailer here: https://github.com/Synchro/PHPMailer), but I got the following error:

Mailer Error: The following From address failed: [email protected]

After I commented out ; extension=php_openssl.dll in php.ini, it is working now.

Solution 5 - Php

In xampp, if "extension=php_openssl.dll" is not present in your php.ini file then add it in the "Windows Extensions" section of your php.ini file and restart your apache. It works for me..

Solution 6 - Php

So, what did we do to make openssl_pkey_new() and all the other openssl_ functions in PHP work...

  • Enabled the extension php_openssl.dll in the (right/active) php.ini. Checked.
  • Checked that there exists a openssl.cnf in xampp\apache\conf\ (and also in two other directories within XAMPP). Checked.
  • Added the environment variable OPENSSL_CONF in the Windows system settings with the full path to the above openssl.cnf. Checked.
  • Restarted Apache (and after that did not work restarted the computer several times...). Checked.

Still does not work, and throwing errors such as

  • error:0E06D06C:configuration file routines:NCONF_get_string:no value
  • error:02001002:system library:fopen:No such file or directory
  • error:2006D080:BIO routines:BIO_new_file:no such file

Okay, here are another two more things to check.

1. Trouble with the environment

Run phpinfo() from a PHP script, and go to the "Apache Environment" section. Check the value of OPENSSL_CONF.

Surprise. This is not what we have set in the windows system settings.

The solution is simple. Set the environment variable in the PHP script.

putenv('OPENSSL_CONF=C:\xampp\apache\conf\openssl.cnf');

2. Trouble with relative filenames

Now, openssl_pkey_new() will work, but openssl_pkey_export_to_file() does still not work and returns false without any further explanation?

Check the filename that you have specified as output filename. It will not work in Windows as long as you do not specify the full path.

$folder = realpath('../keyring');
$outfile = $folder.'/private.pem';
openssl_pkey_export_to_file($key, $outfile);

Solution 7 - Php

You will need to edit your php.ini. It's 4 easy steps.

Find your php.ini file.

$inipath = php_ini_loaded_file();

Enable openssl in the file:

extension=php_openssl.dll 

Turn allow_url_fopen on

allow_url_fopen = On

Restart apache and you are done!

Solution 8 - Php

STEP 1: On your php.ini comment out ;extension=php_openssl.dll

STEP 2: Copy libeay32.dll and ssleay32.dll from your PHP root folder and paste it your Apache/bin folder

STEP 3: Restart Apache

Solution 9 - Php

I am assuming that this question is for those using a windows based system.

After making sure that the extension extension=php_openssl.dll in your php.ini file does not have a semicolon.

Then make sure that you have added C:/xampp/apache/bin into your environment path in order to use openssl without having move the command prompt to that directory C:/xampp/apache/bin

Solution 10 - Php

Although not related to this question but as the WP migrate Pro docs link to this question I though I would post an answer here.

If your having problems with DB Migrate Pro activating instead of enabling SSL you can just add a line of code to your wp-config

define( 'WPMDB_LICENCE', 'XXXXXXXXXXx' );

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMert METİNView Question on Stackoverflow
Solution 1 - PhpMemochipanView Answer on Stackoverflow
Solution 2 - PhpMert METİNView Answer on Stackoverflow
Solution 3 - PhpShahbaz A.View Answer on Stackoverflow
Solution 4 - Phpmacio.JunView Answer on Stackoverflow
Solution 5 - Phpsameer.nunaView Answer on Stackoverflow
Solution 6 - PhpBurninLeoView Answer on Stackoverflow
Solution 7 - PhpRoni davelmanView Answer on Stackoverflow
Solution 8 - PhpmpalenciaView Answer on Stackoverflow
Solution 9 - PhpRudy ListerView Answer on Stackoverflow
Solution 10 - PhpTristanisgingerView Answer on Stackoverflow