24 Apr 2009

Activate OpenSSL extension in PHP

Some time ago I coded a small web page to generate license files for one of my clients. This is a very simple app that basically allows you to enter some customer’s info and generate an encrypted license file. I’m not a PHP developer but the language is very similar to C and a good framework helps a lot.

In my case I use CodeIgniter, which is just great.

Anyway, today I needed to install this app on my laptop (which is running Windows 7 x64 by the way). I installed a fresh copy of XAMPP Lite, created my database and run the app. Everything worked fine except the function that generates the license file.

{% codeblock lang:html %} Fatal error: Call to undefined function openssl_get_privatekey() in C:.… {% endcodeblock %}

My initial reaction was to think that I needed to install the OpenSSL libraries, so I wasted half an hour looking for the files and reading how to install the binaries. But it was easier than that. XAMPPLite already installs all you need, you just need to activate the extensions you need. In this case I needed to edit the php.ini file and uncomment the line:

{% codeblock lang:php %} extension=php_openssl.dll {% endcodeblock %}

If you don’t have the previous line try to add it to your php.ini file.

Also, if you need to know which extensions are activated, a call to phpinfo() will give you the answer.

xampp phpinfo