@e0001ed9 opened this Issue on December 10th 2021

I recently tried upgrading from Matomo 4.5.0 to 4.6.1 (via the docker apache image), and discovered I was no longer able to connect to the UI due to 500s.

Upon enabling debug logging, I discovered numerous errors like the following:

ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] Uncaught exception: Error: Undefined constant "SSL_NO_VERIFY" in /var/www/html/libs/Zend/Db/Adapter/Mysqli.php:320
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] Stack trace:
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/0'>#0</a> /var/www/html/libs/Zend/Db/Adapter/Mysqli.php(320): constant('SSL_NO_VERIFY')
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/1'>#1</a> /var/www/html/core/Db/Adapter/Mysqli.php(81): Zend_Db_Adapter_Mysqli->_connect()
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/2'>#2</a> /var/www/html/libs/Zend/Db/Adapter/Abstract.php(315): Piwik\Db\Adapter\Mysqli->_connect()
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/3'>#3</a> /var/www/html/core/Db/Adapter.php(53): Zend_Db_Adapter_Abstract->getConnection()
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/4'>#4</a> /var/www/html/core/Db.php(156): Piwik\Db\Adapter::factory('MYSQLI', Array)
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/5'>#5</a> /var/www/html/core/Db.php(55): Piwik\Db::createDatabaseObject()
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/6'>#6</a> /var/www/html/core/Db.php(301): Piwik\Db::get()
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/7'>#7</a> /var/www/html/core/Option.php(288): Piwik\Db::fetchAll('SELECT option_v...')
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/8'>#8</a> /var/www/html/core/Option.php(178): Piwik\Option->autoload()
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/9'>#9</a> /var/www/html/core/Option.php(48): Piwik\Option->getValue('marketplace_lic...')
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/10'>#10</a> /var/www/html/plugins/Marketplace/LicenseKey.php(17): Piwik\Option::get('marketplace_lic...')
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/11'>#11</a> /var/www/html/plugins/Marketplace/config/config.php(26): Piwik\Plugins\Marketplace\LicenseKey->get()
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/12'>#12</a> [internal function]: DI\Definition\Source\DefinitionFile->{closure}(Object(DI\Container))
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/13'>#13</a> /var/www/html/vendor/php-di/invoker/src/Invoker.php(82): call_user_func_array(Object(Closure), Array)
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/14'>#14</a> /var/www/html/vendor/php-di/php-di/src/Definition/Resolver/FactoryResolver.php(80): Invoker\Invoker->call(Object(Closure), Array)
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/15'>#15</a> /var/www/html/vendor/php-di/php-di/src/Definition/Resolver/ResolverDispatcher.php(71): DI\Definition\Resolver\FactoryResolver->resolve(Object(DI\Definition\FactoryDefinition), Array)
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/16'>#16</a> /var/www/html/vendor/php-di/php-di/src/Container.php(390): DI\Definition\Resolver\ResolverDispatcher->resolve(Object(DI\Definition\FactoryDefinition), Array)
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/17'>#17</a> /var/www/html/vendor/php-di/php-di/src/Container.php(139): DI\Container->resolveDefinition(Object(DI\Definition\FactoryDefinition))
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/18'>#18</a> /var/www/html/vendor/php-di/php-di/src/Definition/Reference.php(53): DI\Container->get('Piwik\\Plugins\\M...')
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/19'>#19</a> /var/www/html/vendor/php-di/php-di/src/Definition/Resolver/ResolverDispatcher.php(66): DI\Definition\Reference->resolve(Object(DI\Container))
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/20'>#20</a> /var/www/html/vendor/php-di/php-di/src/Definition/Resolver/ParameterResolver.php(78): DI\Definition\Resolver\ResolverDispatcher->resolve(Object(DI\Definition\Reference))
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/21'>#21</a> /var/www/html/vendor/php-di/php-di/src/Definition/Resolver/ObjectCreator.php(138): DI\Definition\Resolver\ParameterResolver->resolveParameters(Object(DI\Definition\ObjectDefinition\MethodInjection), Object(ReflectionMethod), Array)
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/22'>#22</a> /var/www/html/vendor/php-di/php-di/src/Definition/Resolver/ObjectCreator.php(71): DI\Definition\Resolver\ObjectCreator->createInstance(Object(DI\Definition\ObjectDefinition), Array)
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/23'>#23</a> /var/www/html/vendor/php-di/php-di/src/Definition/Resolver/ResolverDispatcher.php(71): DI\Definition\Resolver\ObjectCreator->resolve(Object(DI\Definition\ObjectDefinition), Array)
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/24'>#24</a> /var/www/html/vendor/php-di/php-di/src/Container.php(390): DI\Definition\Resolver\ResolverDispatcher->resolve(Object(DI\Definition\ObjectDefinition), Array)
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/25'>#25</a> /var/www/html/vendor/php-di/php-di/src/Container.php(139): DI\Container->resolveDefinition(Object(DI\Definition\ObjectDefinition))
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/26'>#26</a> /var/www/html/core/Container/StaticContainer.php(81): DI\Container->get('Piwik\\Plugins\\M...')
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/27'>#27</a> /var/www/html/plugins/CorePluginsAdmin/PluginInstaller.php(49): Piwik\Container\StaticContainer::get('Piwik\\Plugins\\M...')
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/28'>#28</a> /var/www/html/vendor/php-di/php-di/src/Definition/Resolver/ObjectCreator.php(143): Piwik\Plugins\CorePluginsAdmin\PluginInstaller->__construct(NULL)
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/29'>#29</a> /var/www/html/vendor/php-di/php-di/src/Definition/Resolver/ObjectCreator.php(71): DI\Definition\Resolver\ObjectCreator->createInstance(Object(DI\Definition\ObjectDefinition), Array)
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/30'>#30</a> /var/www/html/vendor/php-di/php-di/src/Definition/Resolver/ResolverDispatcher.php(71): DI\Definition\Resolver\ObjectCreator->resolve(Object(DI\Definition\ObjectDefinition), Array)
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/31'>#31</a> /var/www/html/vendor/php-di/php-di/src/Container.php(390): DI\Definition\Resolver\ResolverDispatcher->resolve(Object(DI\Definition\ObjectDefinition), Array)
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/32'>#32</a> /var/www/html/vendor/php-di/php-di/src/Container.php(139): DI\Container->resolveDefinition(Object(DI\Definition\ObjectDefinition))
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/33'>#33</a> /var/www/html/vendor/php-di/php-di/src/Definition/Reference.php(53): DI\Container->get('Piwik\\Plugins\\C...')
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/34'>#34</a> /var/www/html/vendor/php-di/php-di/src/Definition/Resolver/ResolverDispatcher.php(66): DI\Definition\Reference->resolve(Object(DI\Container))
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/35'>#35</a> /var/www/html/vendor/php-di/php-di/src/Definition/Resolver/ParameterResolver.php(78): DI\Definition\Resolver\ResolverDispatcher->resolve(Object(DI\Definition\Reference))
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/36'>#36</a> /var/www/html/vendor/php-di/php-di/src/Definition/Resolver/ObjectCreator.php(138): DI\Definition\Resolver\ParameterResolver->resolveParameters(Object(DI\Definition\ObjectDefinition\MethodInjection), Object(ReflectionMethod), Array)
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/37'>#37</a> /var/www/html/vendor/php-di/php-di/src/Definition/Resolver/ObjectCreator.php(71): DI\Definition\Resolver\ObjectCreator->createInstance(Object(DI\Definition\ObjectDefinition), Array)
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/38'>#38</a> /var/www/html/vendor/php-di/php-di/src/Definition/Resolver/ResolverDispatcher.php(71): DI\Definition\Resolver\ObjectCreator->resolve(Object(DI\Definition\ObjectDefinition), Array)
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/39'>#39</a> /var/www/html/vendor/php-di/php-di/src/Container.php(390): DI\Definition\Resolver\ResolverDispatcher->resolve(Object(DI\Definition\ObjectDefinition), Array)
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/40'>#40</a> /var/www/html/vendor/php-di/php-di/src/Container.php(199): DI\Container->resolveDefinition(Object(DI\Definition\ObjectDefinition), Array)
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/41'>#41</a> /var/www/html/core/Http/ControllerResolver.php(75): DI\Container->make('Piwik\\Plugins\\C...')
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/42'>#42</a> /var/www/html/core/Http/ControllerResolver.php(49): Piwik\Http\ControllerResolver->createPluginController('CorePluginsAdmi...', 'safemode')
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/43'>#43</a> /var/www/html/core/FrontController.php(604): Piwik\Http\ControllerResolver->getController('CorePluginsAdmi...', 'safemode', Array)
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/44'>#44</a> /var/www/html/core/FrontController.php(168): Piwik\FrontController->doDispatch('CorePluginsAdmi...', 'safemode', Array)
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/45'>#45</a> /var/www/html/core/FrontController.php(99): Piwik\FrontController->dispatch('CorePluginsAdmi...', 'safemode', Array)
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/46'>#46</a> /var/www/html/core/FrontController.php(139): Piwik\FrontController::generateSafeModeOutputFromError(Array)
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/47'>#47</a> /var/www/html/core/FrontController.php(189): Piwik\FrontController::generateSafeModeOutputFromException(Object(Error))
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/48'>#48</a> /var/www/html/core/FrontController.php(99): Piwik\FrontController->dispatch('CorePluginsAdmi...', 'safemode', Array)
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/49'>#49</a> /var/www/html/core/FrontController.php(139): Piwik\FrontController::generateSafeModeOutputFromError(Array)
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/50'>#50</a> /var/www/html/core/FrontController.php(189): Piwik\FrontController::generateSafeModeOutputFromException(Object(Error))
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/51'>#51</a> /var/www/html/core/FrontController.php(99): Piwik\FrontController->dispatch('CorePluginsAdmi...', 'safemode', Array)
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/52'>#52</a> /var/www/html/core/FrontController.php(139): Piwik\FrontController::generateSafeModeOutputFromError(Array)
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/53'>#53</a> /var/www/html/core/FrontController.php(189): Piwik\FrontController::generateSafeModeOutputFromException(Object(Error))
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/54'>#54</a> /var/www/html/core/FrontController.php(99): Piwik\FrontController->dispatch('CorePluginsAdmi...', 'safemode', Array)
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/55'>#55</a> /var/www/html/core/FrontController.php(274): Piwik\FrontController::generateSafeModeOutputFromError(Array)
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/56'>#56</a> [internal function]: Piwik\FrontController::triggerSafeModeWhenError()
ERROR Piwik\FrontController[2021-12-10 02:51:54 UTC] [857fb] <a href='/57'>#57</a> {main}

I am using Matomo with Google's Cloud SQL, which provides self-signed certificates, so I think I have to use ssl_no_verify = 1 (though I'd love not to use that setting if anyone knows a workaround). Removing this setting, as expected, led to Matomo not being able to connect to the database due to certificate verification issues.

Expected Behavior

I expected Matomo to continue to connect successfully to the database with SSL enabled, but verification disabled.

Current Behavior

Matomo is unable to connect to the database and returns 500.

Possible Solution

I noticed that both PHP and Zend received major upgrades between the two docker images for 4.5.0 and 4.6.1. Perhaps this led to incompatibilities?

4.5.0

➜  ~ docker run -ti matomo:4.5.0-apache bash -c 'uname -a && php -v'
Linux f98aac68bbec 5.11.0-41-generic <a href='/45'>#45</a>~20.04.1-Ubuntu SMP Wed Nov 10 10:20:10 UTC 2021 x86_64 GNU/Linux
PHP 7.4.26 (cli) (built: Dec  2 2021 14:25:17) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.26, Copyright (c), by Zend Technologies

4.6.1

➜  ~ docker run -ti matomo:4.6.1-apache bash -c 'uname -a && php -v'
Linux fe5285d4b0d8 5.11.0-41-generic <a href='/45'>#45</a>~20.04.1-Ubuntu SMP Wed Nov 10 10:20:10 UTC 2021 x86_64 GNU/Linux
PHP 8.0.13 (cli) (built: Dec  2 2021 13:29:44) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.13, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.13, Copyright (c), by Zend Technologies

Steps to Reproduce (for Bugs)

  1. Run the docker 4.6.1-apache image
  2. Configure it to connect to a database with a self-signed certificate, but with ssl_no_verify enabled.
  3. It should not be able to connect to the database and logs the errors above.

Context

I'm also using the MySQLi adapter. Here is the database configuration:

[database]
<redacted>
adapter = "MYSQLI"
enable_ssl = 1
ssl_ca = "/opt/lib/mysql-ssl/server-ca.pem"
ssl_cert = "/opt/lib/mysql-ssl/client-cert.pem"
ssl_key = "/opt/lib/mysql-ssl/client-key.pem"
ssl_no_verify = 1

Impact - I'm unable to upgrade to 4.6.1 from 4.5.0.

Your Environment

  • Matomo Version: 4.6.1
  • PHP Version: PHP 8.0.13
  • Server Operating System: 20.04.1-Ubuntu
  • Additionally installed plugins: none
@sgiehl commented on December 10th 2021 Member

Hi @e0001ed9.
Thanks for the report. Could you maybe try if changing some code solves your issue.
Could you try adding 'ssl_no_verify' => null, to this array definition:
https://github.com/matomo-org/matomo/blob/0cbcdadf5a972d531b7d5e78afa21a71004a9777/libs/Zend/Db/Adapter/Mysqli.php#L303-L309
It's not a final solution, but if it works I might be able to provide a proper fix.

@e0001ed9 commented on December 11th 2021

@sgiehl That did appear to work!

Disclaimer - I only tested this in a local test setup with docker so as not to impact my production deployment, but I can confirm that test setup did exhibit the problem above without your suggested change, then resolved with that fix :tada:

@justinvelluppillai commented on December 13th 2021 Contributor

By the way this issue is probably related to the docker image using PHP8 vs 7.4, rather than the upgrade from Matomo 4.5.0 to 4.6.1

@e0001ed9 commented on December 13th 2021

Totally makes sense @justinvelluppillai - thanks! Since I use Matomo via the official docker images, it wasn't immediately obvious that those other dependencies had changed along with the Matomo version.

This Issue was closed on December 14th 2021
Powered by GitHub Issue Mirror