-
Notifications
You must be signed in to change notification settings - Fork 111
mcrypt is deprecated in PHP7.1 #98
Comments
Can you give just a bit more context of when that fatal error occured? Mcrypt should throw deprecated warnings in PHP 7.1, but not crash... |
I have my error reporting turned all the way up (E_ALL), so I'm not hiding anything when I code. If your settings are different, you may not get these errors. |
Magento defaults to throwing an Exception on all errors (including warnings, notices, and deprecations) if the developer mode is enabled (with Ideally the class could be overridden, but I don't think it'd be trivial to make a compatible drop-in replacement for the whole thing. It looks like |
I do have developer mode enabled on my local machine... so that may be why I'm getting those fatal errors. But yeah, I figured it would be a pretty tedious fix, considering how often |
Is there anyway to ignore depreciation messages for mcrypt only? Or can we just patch to use a different function? |
@ivanweiler found a way to patch and not use mcrypt. What I've seen so far looks great, I'm awaiting the pull request from him. |
@icurdinj any updates? |
Hello all, this is going to be a long one, sorry :) There are 3 things using mcrypt in M1:
My initial (optimistic) idea was to write new Openssl adapter and change main encryption model to use it (same is mentioned for LTS project).
Mcrypt / Openssl compatibility It's important to note that mcrypt always used zero padding for encryption, which is considered bad practice these days. Openssl is using PKCS#7, but it can be forced to use less secure zero padding.
Solution 1 phpseclib/mcrypt_compat - basically polyfill for mcrypt This requires adding Composer support in M1!!, but no code change is required, MCRYPT_ constants in EE are compensated so you can disable mcrypt on server. Ofc, mcrypt_compat is also using zero padding since it's trying to be fully compatible with old mcrypt. Solution 2 Varien_Io_Sftp can't be switched to openssl without updating phpseclib. install.xml can't be "rewritten" to remove mcrypt dependency from install, model that loads install.xml can, so it's a dirty hack either way. Anyway, I would like to hear what others think is the best way to handle this, since I'm not sure at this point :) P.S. I see that openssl is going to be deprecated in 7.2 by libsodium? Will this be used for AES in the future, should we wait a bit? P.S.2. I'm curious to see how M2 is going to handle this, since mcrypt code and (EE) encryption adapter was just ported to M2 |
A master has spoken :-) I've just implemented solution 1 to our composer.json - it now suggests installing phpseclib/mcrypt_compat. Install that, disable mcrypt, and it should just work. Having said that, it's better to simply not bother with PHP 7.1: https://github.com/Inchoo/Inchoo_PHP7/wiki/RunningOnPHP7.1 About solution 2: yes, it's out of scope of this module, but I can't wait to see @ivanweiler making a better security module based on libsodium... |
Any update on this ? I thinks this is the M2 related bug: |
@ivanweiler, @icurdinj but with "mcrypt_compat" you have to update phpseclib. i've created an simple "module" wich doing this job well. based on Solution 2. https://github.com/mklooss/Magento_Varien_Crypt_Mcrypt but i will also take a look at an other solution based on openssl, but the convert job will be the hardest part |
This presentation an these 2 slides in particular should be helpful to explore other solutions based on openSSL I think the start point is to create a class in /lib/Varian/Crypt/OpenSSL.php implenting the methods init() encrypt() , decrypt() so something like this:
|
Little update regarding mcrypt. We wrote openssl adapter that should be fully compatible with both CE (blowfish) and EE (aes) on php >= 7.1.8. Code can be seen in current develop branch For devs that are using composer with Magento1, mcrypt_compat will still be recommended way to move away from mcrypt. For devs that don't want to use composer, this should work just fine for encryption/decryption. Anyway, if someone care to test a bit (on latest CE && EE 1.x versions), that would be great !! We're planning new version of extension one of these days. It works out of the box on CE, on EE please uncomment this line to replace default EE encryptor:
Regards |
thanks for the workaround, just one request, could you move the code pool to community or keep Varien_Crypt compatible to override the enc. model static public function factory($method='mcrypt')
{
$uc = str_replace(' ','_',ucwords(str_replace('_',' ',$method)));
$className = 'Varien_Crypt_'.$uc;
return new $className;
} |
Fatal error: Uncaught Exception: Deprecated functionality: Function mcrypt_module_open() is deprecated in \lib\Varien\Crypt\Mcrypt.php on line 63 in \app\code\core\Mage\Core\functions.php on line 245
Not sure exactly what to do about this as I'm not sure if these classes can be overridden.
As an interim solution, you can add
to the top of
\lib\Varien\Crypt\Mcrypt.php
.The text was updated successfully, but these errors were encountered: