help with this: Fatal error: mcrypt_create_iv()

Jump to: navigation, search

Hi, i'm trying to install mediawiki 1.18.2, using a MySQL 5.0 database, and when i start, before getting complete it shows me this error.


Fatal error: mcrypt_create_iv() [<a href='function.mcrypt-create-iv'>function.mcrypt-create-iv</a>]: Could not gather sufficient random data in D:\Hosting\9176902\html\web\mediawiki-1.18.2\includes\CryptRand.php on line 281


could someone help me with that?

189.237.51.6722:14, 11 April 2012

A pretty common error lately. Second time I've seen problems with people being unable to use a randomization function during installation.

Jasper Deng (talk)22:17, 11 April 2012

I see, do you know how could I solve it? or complete the installation?

189.237.51.6722:32, 11 April 2012

Try an earlier version of MediaWiki like 1.18.0 (which works for me), or trunk (1.20alpha).

Jasper Deng (talk)22:33, 11 April 2012

I'll try that, thanks

189.237.51.6722:46, 11 April 2012

But I'll warn you that this is a pretty rampant bug. There's another thread on this support desk about it.

Jasper Deng (talk)22:49, 11 April 2012

btw, where can I find the 1.18 version, as page only shows 1.18.2 ?

189.237.51.6722:51, 11 April 2012

Damn. It looks like you'll have to go w/ 1.17.3 then :( I lied

See [1].

Jasper Deng (talk)22:54, 11 April 2012
 
 
 
 
 
 

ugh, that's a horrible reason to create a fatal error /me glares at php.

Bawolff (talk)00:11, 12 April 2012
 

What version of PHP?

Reedy (talk)13:43, 12 April 2012

it's PHP 5.3, i tried with 1.18 and 1.17 and it still showing the same error.

189.237.51.6714:07, 12 April 2012

Yeah, they've both got the same code. It's a PHP related issue though...

Reedy (talk)17:36, 15 April 2012
 
 

so, there is no solution for that problem yet? does someone know how to fix it?(instead of the options showed on this post, as they don't woek)

189.237.51.6717:52, 12 April 2012

Well work around is to use 1.18.1 (note .1 not .2. It can be downloaded from http://svn.wikimedia.org/svnroot/mediawiki/tags/REL1_18_1/phase3/ . If you don't have an svn client to download it though, it will be a pain to download). Note however this is missing some security fixes, and is insecure (The issue you're experiencing is the patch to make stuff secure gone slightly wrong).

Bawolff (talk)23:49, 13 April 2012

Having the same problem. Tried with 1.18.1 and 1.18.2. Nothing works! Anyone able to find a way around this?

68.48.41.11408:56, 14 April 2012

Tried with two other builds, alpha and beta. Still giving same error: "Could not gather sufficient random data in ....\includes\CryptRand.php on line 281". I guess this is a major issue. Did anyone have any luck with this?

68.48.41.11421:49, 14 April 2012

Oh, I am using PHP 5.3 and MySQL 5 btw.

68.48.41.11421:50, 14 April 2012

What kind of webhost do you have? The PHP had better be later or earlier than 5.3.1.

Jasper Deng (talk)00:38, 15 April 2012

I am using GoDaddy Deluxe Hosting.

68.48.41.11401:03, 15 April 2012

Hhm... Check your Special:Version. If it says "fast-cgi" or any other thing mentioning "cgi" for your PHP, then you have Windows IIS. I don't know about it, but GoDaddy just might restrict the required functions, as many webhosts tend to do so, but I doubt that for such a basic and fundamental function like the randomization functions.

Jasper Deng (talk)01:09, 15 April 2012

I just started out with this host so I can switch operating systems relatively quickly. I am migrating from Windows to Linux right now. I'll see if that makes a difference.

68.48.41.11401:39, 15 April 2012
 

Note, fast-cgi can be used under linux, its just not anywhere near as popular. Generally you'd get a different error message if your host is the one restricting the function.


I wonder if this entire thing is a typo in php source. They have the exact same error in two place, in one place its a warning, in the other its a fatal.

Bawolff (talk)02:00, 15 April 2012
 
 
 
 

Tried with two other builds, alpha and beta. Still giving same error: "Could not gather sufficient random data in ....\includes\CryptRand.php on line 281". I guess this is a major issue. Did anyone have any luck with this?

If you get that error message when using 1.18.1 then you did something wrong (Since CryptRand.php doesn't exist in 1.18.1). So if you get that error message, then you're not actually using 1.18.1.

Bawolff (talk)01:45, 15 April 2012

Alternative work around (Note, this will potentially make your wiki somewhat less secure. I'm not exactly sure how much less secure (or more generally what the security implications actually are. You may want to modify $wgSecretKey in your LocalSettings.php to make it more random after your done the install if you do this)

  • Locate the file includes/CryptRandom.php.
  • Find the following line (probably around line 289):
$iv = mcrypt_create_iv( $rem, MCRYPT_DEV_URANDOM );
  • Change it to:
$iv = mcrypt_create_iv( $rem, MCRYPT_RAND );

See if things work (Make sure to do a hard refresh of the install page/re-start the install). I'm not sure if this will work, so i'd be very interested to hear if that actually fixes the issue.

Bawolff (talk)02:09, 15 April 2012

New to MediaWiki but the change for MCRYPT_DEV_URANDOM to MCRYPT_RAND allowed me to generate the LocalSettings.php file and finish my install.

Not sure how it effects the actual security/randomness but I am at least able to use the wiki.

Iankarlwallace (talk)22:28, 15 April 2012
 

Thanks that really worked for me. I am using windows hosting of godaddy. after changing this installation get completed. I am using the latest release of media wiki.

122.162.138.7518:53, 1 May 2013
 

Bawolff, you are right, I had uploaded the wrong files by mistake, when trying to upload 1.18.1.

Your changes above fixed my problems as well. Thank you!

130.85.242.22716:39, 16 April 2012
 
 
 
 
 

I just asked to Godaddy support to help me with the installation (that's my Hosting provider), and they did, but they told me it was a a problem between PHP and wiki PHP, but it was only at windows servers, as on Linux it doesn't have any problem.

189.237.51.6717:56, 16 April 2012
 

I got this error on my Windows 2003 system when I upgraded to MediaWiki 1.19.1 (from MediaWiki 1.18.0) with these components:

  • IIS 6
  • FastCGI 1.5
  • PHP 5.3.3 (Non Thread Safe VC9)
  • PostgreSQL 9.0.0-1

The error was resolved when I upgraded to PHP 5.3.16 (Non Thread Safe VC9).

Onu (talk)00:17, 30 August 2012