Post by locksdownunder » Wed Jul 10, 2019 7:24 pm

Hello I have just installed OC and all runs fine on my windows PC using chrome.
On my android phone I get the following fatal error
Call to undefined function openssl_random_pseudo_bytes(0) in ...../system/library/session.php on line 62

I have checked php.ini on the server it has

Code: Select all

extension=openssl.so
;extension=intl.so
extension=pgsql.so
;extension=soap.so
;extension=xsl.so
;extension=yaml.so
;extension=memcached.so
;extension=memcache.so
;extension=gmp.so
;extension=mongo.so
;extension=mongodb.so
extension=php_openssl.dll
PHP = 5.6.4
OC = 3.0.3.2


Posts

Joined
Wed Jul 10, 2019 7:15 pm
Location - Australia

Post by Johnathan » Wed Jul 10, 2019 9:23 pm

This is a pretty common error message I've seen in OpenCart 3.0, due to a switch in the encryption library. There is a fix suggested in the forums here, though I haven't tried this myself:

viewtopic.php?f=198&t=204707&p=740186#p737628

If you prefer instead to try and switch back to the older OpenCart 2.3 version of the encryption library, you can make these edits:

Code: Select all

------------------------------------------------------------------------------
IN:
/system/library/encryption.php

REPLACE:
return strtr(base64_encode(openssl_encrypt($value, 'aes-128-cbc', hash('sha256', $key, true))), '+/=', '-_,');

WITH:
return strtr(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, hash('sha256', hash('sha256', $key, true), true), $value, MCRYPT_MODE_ECB)), '+/=', '-_,');

AND REPLACE:
return trim(openssl_decrypt(base64_decode(strtr($value, '-_,', '+/=')), 'aes-128-cbc', hash('sha256', $key, true)));

WITH:
return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, hash('sha256', hash('sha256', $key, true), true), base64_decode(strtr($value, '-_,', '+/=')), MCRYPT_MODE_ECB));
------------------------------------------------------------------------------

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by locksdownunder » Thu Jul 11, 2019 4:48 pm

Unfortunately that modification does not fix the problem.
Note my problem is with "openssl_random" not openssl_encrypt

unless there is some sort of system refresh I need to do?


Posts

Joined
Wed Jul 10, 2019 7:15 pm
Location - Australia

Post by ADD Creative » Thu Jul 11, 2019 5:08 pm

It looks like your OpenSSL PHP extension is not enabled. Your PC probably already has a session cookie, whereas you phone might not. You might find if you delete the cookies in Chrome on your PC you will start getting the same error.

Check your phpinfo() to see if it has OpenSSL support enabled.

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by locksdownunder » Thu Jul 11, 2019 6:11 pm

it appears to be there and enabled
Image


Posts

Joined
Wed Jul 10, 2019 7:15 pm
Location - Australia

Post by ADD Creative » Thu Jul 11, 2019 7:01 pm

That looks correct. Does openssl_random_pseudo_bytes work when in a PHP file on its own? Try something link the code below it you have error reporting on.

Code: Select all

<?php
$randnumber = openssl_random_pseudo_bytes(26);
?>

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by locksdownunder » Fri Jul 12, 2019 4:20 am

The code below runs fine on both PC and android device without any error.

Code: Select all

<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$randnumber = openssl_random_pseudo_bytes(26);
echo $randnumber;
?>


Posts

Joined
Wed Jul 10, 2019 7:15 pm
Location - Australia

Post by ADD Creative » Fri Jul 12, 2019 5:51 pm

Did you try deleting the cookies on your PC and refreshing the page? Did same error start then appearing?

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by locksdownunder » Fri Jul 12, 2019 6:06 pm

Yes deleting the cookies now makes the website crash on my PC.
www.locksdownunder.com/shop/

Although the test.php works fine
www.locksdownunder.com/test.php


Posts

Joined
Wed Jul 10, 2019 7:15 pm
Location - Australia

Post by ADD Creative » Sat Jul 13, 2019 5:22 am

Could be you have something in your .htaccess, php.ini or user.ini in the shop folder that causing PHP to be configured differently. Try your test.php in the shop folder.

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by locksdownunder » Sat Jul 13, 2019 6:47 am

Thank you for your persistance
Yes it is the php.ini file in the shop directory causing the problem. If I rename it then my test.php works

Again Thank you!!!!


Posts

Joined
Wed Jul 10, 2019 7:15 pm
Location - Australia
Who is online

Users browsing this forum: ianhaney50, paulfeakins and 28 guests