Search code examples
pythonpython-2.7sslcurlmatomo

Curl request failing over SSL


I am trying to setup Piwik as an analytics tool and have it process my Nginx access logs. For some reason python is having trouble connecting to Piwik, I believe it is because my site is only served over SSL but I'm not really sure what the error means. When I run the following command:

sudo python /home/forge/example.com/piwik/misc/log-analytics/import_logs.py --url=https://example.com/piwik --idsite=1 --recorders=4 --enable-http-errors --enable-http-redirects --enable-static --enable-bots /var/log/nginx/example.com-access.log

I get back the following:

[INFO] Error when connecting to Piwik: <urlopen error [Errno 1] _ssl.c:510: error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert internal error>
[INFO] Retrying request, attempt number 2

I believe this is Curl failing over SSL but I'm not certain. Has anyone had this problem before or have any more info on this error?


Solution

  • The problem turned out to be that the site was using CloudFlare SSL which uses SNI. Support for SNI wasn't added to python until 2.7.7. Upgrading to 2.7.10 fixed the problem!