curl-and-python

Re: curl-and-python Digest, Vol 60, Issue 2

From: John Skopis <jskopis_at_lakeshoreint.com>
Date: Tue, 16 Aug 2011 10:22:33 -0500

On 08/16/2011 05:00 AM, curl-and-python-request_at_cool.haxx.se wrote:
>> I am wondering if you know of a better way to initialize setup CAINFO to
>> > something useful besides hardcoding the path in do_curl_new. Running strings
>> > on libcurl reveals the path to CAINFO.
> libcurl has a default path for CAINFO set internally. If you need to change
> that then it is entirely up to your app how to do it!

The app is pycurl. Running the test below fails because CAINFO is set to
None in pycurl.

I am wondering what is the best way to initialize pycurl.CAINFO, using
the library default?

If you look at the earlier code, I had hardcoded setting the path in the
pycurl Curl constructor. Rather than hardcoding the path I think it
makes more sense to ask libcurl for the default path.

Or, did I compile libcurl incorrectly? Is curl supposed to use the
deafult if CAINFO/CAPATH is not set?

Thanks again,
John

import sys
import pycurl

class Test:
     def __init__(self):
         self.contents = ''

     def body_callback(self, buf):
         self.contents = self.contents + buf

print >>sys.stderr, 'Testing', pycurl.version

t = Test()
c = pycurl.Curl()
#c.setopt(pycurl.CAINFO,'/etc/pki/tls/certs/ca-bundle.crt')
c.setopt(c.URL, 'https://www.google.com/')
c.setopt(c.WRITEFUNCTION, t.body_callback)
c.perform()
c.close()

print t.contents

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2011-08-16