Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacement of mcrypt and usage of mcryptcompat in Magento 1.9.4.x and 20.x (mcrypt is deprecated) #1211

Closed
seansan opened this issue Sep 16, 2020 · 8 comments

Comments

@seansan
Copy link
Contributor

seansan commented Sep 16, 2020

Getting some mcrypt warnings after I pulled 20.x yesterday we are on php 7.2.33

Am I missing something?

Deprecated: Function mcrypt_module_open() is deprecated in public_html/lib/Varien/Crypt/Mcrypt.php on line 74
Deprecated: Function mcrypt_enc_get_iv_size() is deprecated in public_html/lib/Varien/Crypt/Mcrypt.php on line 83
Deprecated: Function mcrypt_create_iv() is deprecated in public_html/lib/Varien/Crypt/Mcrypt.php on line 83
Deprecated: Function mcrypt_enc_get_key_size() is deprecated in public_html/lib/Varien/Crypt/Mcrypt.php on line 87
Deprecated: Function mcrypt_generic_init() is deprecated in public_html/lib/Varien/Crypt/Mcrypt.php on line 94
Deprecated: Function mdecrypt_generic() is deprecated in public_html/lib/Varien/Crypt/Mcrypt.php on line 130
Deprecated: Function mdecrypt_generic() is deprecated in public_html/lib/Varien/Crypt/Mcrypt.php on line 130

Funny. I am missing these files and this code in latest 20.x pull ... ce5c202

ce5c202

@seansan seansan added the bug label Sep 16, 2020
@seansan
Copy link
Contributor Author

seansan commented Sep 30, 2020

OK I have learnt some things and I think it is good to share here; also 1 remaining question then this issue can be closed ;)

Learnings

  • mcrypt is deprected as of php 7.2; although it can still be loaded via ini files
  • to find out if mcrypt via php is used, use this command php --ini | grep mcrypt
  • it can also be installed via pecl as a module

Since Magento 19.4.x with php 7.2 support the phpseclib lib and mcryptcompat methods have been introduced as a fall back for the deprecation of mcrypt. Important to know is that mcryptcompat will only be used if you disable mcrypt via your ini settings and restart php. Otherwise mcryptcompat will not be used. Btw mcryptcompat is required in the header lines of app/mage.php.

Fixing it

After disabling mcrypt via the php ini files we saw Magento falls back on mcryptcompat.

Mcryptcompat sources can be found here https://github.com/phpseclib/mcrypt_compat and phpseclib3 here https://github.com/phpseclib/phpseclib - but there are some changes so dont just upgrade

I am closing this issue now

@seansan seansan changed the title Is crypt update to ssl in v 20.x release? Replacement of mcrypt and usage of mcryptcompat in Magento 1.9.4.x and 20.x (mcrypt is deprecated) Sep 30, 2020
@seansan seansan closed this as completed Sep 30, 2020
@joshua-bn
Copy link
Contributor

@seansan do you find any performance changes between using the two?

@seansan
Copy link
Contributor Author

seansan commented Oct 6, 2020 via email

@colinmollenhour
Copy link
Member

I think someone tested at some point and of course it depends on how many times you call it but it wasn't insignificant. Could you just disable E_DEPRECATED in production?

@seansan
Copy link
Contributor Author

seansan commented Oct 7, 2020 via email

@joshua-bn
Copy link
Contributor

Use the PECL mcrypt lib and disable E_DEPRECATED

@colinmollenhour
Copy link
Member

Could you just disable E_DEPRECATED in production?
What do you mean?

Set the error_reporting value to not show E_DEPRECATED. For example this is the default php.ini:

; Development Value: E_ALL
; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT
; http://php.net/error-reporting
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT

Stated differently: just because there is a deprecation warning doesn't mean you have to immediately cease using the code, you can just ignore the warning.. :)

@seansan
Copy link
Contributor Author

seansan commented Oct 7, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants