curl-and-python
Error 60: SSL failed under pycurl, but works under normal curl
Date: Tue, 9 Jan 2018 16:43:05 +0100
System: windows 7.
Pycurl version:
PycURL/7.43.0.1 libcurl/7.57.0 OpenSSL/1.1.0g zlib/1.2.11
c-ares/1.13.0 libssh2/1.8.0
curl version:
curl 7.57.0 (x86_64-pc-win32) libcurl/7.57.0 WinSSL zlib/1.2.11
Python code that doesn't work:
import pycurl
from io import BytesIO
buffer = BytesIO()
curl = pycurl.Curl()
curl.setopt(curl.URL, "https://us17.api.mailchimp.com/3.0/")
curl.setopt(curl.VERBOSE, 1)
curl.setopt(curl.USERNAME, "somename")
curl.setopt(curl.USERPWD, "mypassword")
curl.perform()
curl.close()
# print(buffer.getvalue().decode("iso-8859-1"))
Gives output:
| * Trying 104.73.155.19...
| * TCP_NODELAY set
| * Connected to us17.api.mailchimp.com (104.73.155.19) port 443 (#0)
| * ALPN, offering http/1.1
| * SSL certificate problem: unable to get local issuer certificate
| * Closing connection 0
| Traceback (most recent call last):
| File "C:/Users/User/.PyCharmCE2017.3/config/scratches/scratch.py",
line 12, in <module>
| curl.perform()
| pycurl.error: (60, 'SSL certificate problem: unable to get local
issuer certificate')
curl command that does work:
curl https://us17.api.mailchimp.com/3.0/ -verbose --user
"somename:[REDACTED]" --request GET
Output: Gives a note that the request parameter is superficial. Also
logs a lot of things and gives a good result and the expected JSON
string as data. Has no problem establishing a SSL/TLS connection.
PROBLEM: pycurl doesn't seem to be able to establish a connection.
Judging by curl working, curllib isn't the problem and neither is the
server.
As noted on the pycurl docs, I tried it both with python version and
with the curl version, and got different results indeed. The only
assumption I have left is that it might have something to do with
pycurl reading the user variable different - but there's no single
"user" flag that pycurl knows about, and there's nothing that it says
about this or any other case like it.
The request I did was in a getting started guide here:
http://developer.mailchimp.com/documentation/mailchimp/guides/get-started-with-mailchimp-api-3/
It gives the example only for normal curl, in the following way:
| curl --request GET \
| --url 'https://<dc>.api.mailchimp.com/3.0/' \
| --user 'anystring:<your_apikey>'
the command line curl version working means that I don't think this
issue is due to curl or the server i'm talking to, and honestly im at
a loss where the issue can be in this case, probably because this is
my first time dealing with HTTP requests or internet communication on
this level.
-- Jacco van Dorp
_______________________________________________
https://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2018-01-09