matomo-log-analytics
matomo-log-analytics copied to clipboard
When importing logs, if --url= is set to HTTP url and Piwik is forced to use SSL then importing logs fails
When importing logs in Piwik and when Piwik is configured to use SSL by default, if you specify --url=http://piwik.example.org
then Piwik will fail with this error:
2014-11-20 11:40:10,643: [DEBUG] Error when connecting to Piwik: <urlopen error Piwik returned an invalid response: <!DOCTYPE html>
The solution is to set the --url
parameter to https://....
when importing logs.
To fix this issue, we could maybe detect the URL redirect from HTTP to HTTPS and make Log importer detect that HTTPS should be used.
Migrated from piwik/piwik#6699
With https I get this. Error when connecting to Piwik: < urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590) >
With Python 2.7.9 release the default HTTPS behaviour has changed, which is now to always verify the remote HTTPS certificate to which you are initiating a connection.
Workaround: You have to edit import_logs.py
After "import textwrap" add this:
import ssl
try:
_create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
# Legacy Python that doesn't verify HTTPS certificates by default
pass
else:
# Handle target environment that doesn't support HTTPS verification
ssl._create_default_https_context = _create_unverified_https_context
@mattab: Maybe you should implement an option to disable TLS cert checking.
Hi @shellshocker - if you could open a Pull request, it would be very welcome!
This issue was not fixed: if force_ssl=1
in the config.ini.php then importing the logs specifying HTTP:// will not work.
Just revisited Piwik after several months absence - got further with installation this time, however I cannot import log files (JS is not an option).
Our site uses HTTPS (with HTTP being redirected to HTTPS).
Neither
--url=http://site.com
nor
--url=https://site.com
works. I always get the error:
[INFO] Error when connecting to Piwik: <urlopen error Piwik returned an invalid response: <!DOCTYPE html>
...and it proceeds to dump the HTML from the site.
Let me know if there's something I can try/tweak or provide any other feedback. Happy to help. Just want to get this baby to work :-(