Skip to content

Advanced Reports Not valid cipher method. #19894

@djfordz

Description

@djfordz

Preconditions (*)

  1. Magento 2.3.0
  2. PHP 7.2.10
  3. MariaDB 10.1.37

Steps to reproduce (*)

  1. Set cron to generate advanced reports.
  2. or Run advanced reports cron manually

Expected result (*)

  1. [Screenshots, logs or description]
  2. advanced reports csv is generated

Actual result (*)

  1. [Screenshots, logs or description]
  2. Get output "Not valid cipher method."

The issue is due to openssl_get_cipher_list() returning cipher list in lowercase. The cipher being used in advanced reports is hardcoded in uppercase. So array_search does not match the cipher to the list.

/**
     * Cipher method for encryption.
     *
     * @var string
     */
    private $cipherMethod = 'AES-256-CBC';

but when dumping result of method

private function validateCipherMethod($cipherMethod)
    {
        $methods = openssl_get_cipher_methods();
        return (false !== array_search($cipherMethod, $methods));
    }

openssl_get_cipher_methods() returns list in lowercase.

[02:08 dford@fu mage225] > php72 ~/test.php 
Array
(
    [0] => aes-128-cbc
    [1] => aes-128-cbc-hmac-sha1
    [2] => aes-128-cbc-hmac-sha256
    [3] => aes-128-ccm
    [4] => aes-128-cfb
    [5] => aes-128-cfb1
    [6] => aes-128-cfb8
    [7] => aes-128-ctr
    [8] => aes-128-ecb
    [9] => aes-128-gcm
    [10] => aes-128-ocb
    [11] => aes-128-ofb
    [12] => aes-128-xts
    [13] => aes-192-cbc
    [14] => aes-192-ccm
    [15] => aes-192-cfb
    [16] => aes-192-cfb1
    [17] => aes-192-cfb8
    [18] => aes-192-ctr
    [19] => aes-192-ecb
    [20] => aes-192-gcm
    [21] => aes-192-ocb
    [22] => aes-192-ofb
    [23] => aes-256-cbc
    [24] => aes-256-cbc-hmac-sha1
    [25] => aes-256-cbc-hmac-sha256
    [26] => aes-256-ccm
....

So returns false due to mismatch, either need to use strtoupper() on both or check the return result and change the array_search accordingly. suggest fix below

array_search(strtolower($search), array_map('strtolower', $array));

private function validateCipherMethod($cipherMethod)
{
    $methods = openssl_get_cipher_methods();
    return (false !== array_search(strtolower($cipherMethod), array_map('strtolower', $methods)));
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue: Format is validGate 1 Passed. Automatic verification of issue format passed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions