18

I am getting this exception when trying to run my PHP unit tests:

Fatal error: Call to undefined function openssl_random_pseudo_bytes()

What does it mean?

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Kevin Burke
  • 61,194
  • 76
  • 188
  • 305

7 Answers7

25

I had the same issue. I solved it by editing my php.ini file - changing ;extension=php_openssl.dll to extension=php_openssl.dll .

(For my installation, my php.ini file was located in my P:\Program Files\EasyPHP-12.1\conf_files\ directory.)

ban-geoengineering
  • 18,324
  • 27
  • 171
  • 253
10

Your version of PHP wasn't compiled with the openssl module. If you are building from source, add the module like so:

cd /path/to/php-5.4/
./configure --with-openssl
Kevin Burke
  • 61,194
  • 76
  • 188
  • 305
4

It means you do not have the openssl extension enabled in your PHP install. It needs to be enabled for you to use openssl_* functions.

John Conde
  • 217,595
  • 99
  • 455
  • 496
4

It means you possibly don't have openssl enabled.

If you are on windows its even easier to load it. Enable it from wamp icon on system tray.

enter image description here

enter image description here

hitesh israni
  • 1,742
  • 4
  • 25
  • 48
2

Check your configuration php.ini:

; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
;extension_dir = "./"
; On windows:
extension_dir = "ext"
extension=php_openssl.dll
CamelTM
  • 1,225
  • 12
  • 17
1

Your php installation either does not have openssl enabled, or you could be running a version of php < 5.3.

To enable openssl, you must re-compile and install php with the "–with-openssl" flag. See php installation documentation

Tommy McGlynn
  • 76
  • 1
  • 5
0

For me this error occurred because i had not configured openssl correctly for my PHP. This is the exact step i followed to rectify this error. https://stackoverflow.com/a/36070260/1221096